Web Development

How do you check for the elapsed time in Go Lang? Simple! Use the time.Since function

Go Lang Code for Time Since

package main

import (
  "fmt"
  "time"
)

func main() {
  now := time.Now().UTC()
  time.Sleep(100 * time.Millisecond)
  fmt.Println("now is a type of: ", time.Since(now))
}

Output

$ go run time_elapsed.go 
now is a type of:  100.582296ms