Golang time.Since() function example

package time

Golang time.Since() function usage example

 package main

  import (
 "fmt"
 "time"
  )

  func main() {

 start := time.Now() // get current time

 // some function
 fmt.Println("Hello World!")

 elapsed := time.Since(start) //<------------------ here !
 fmt.Printf("Print Hello World took %s\n", elapsed)
  }

References :

http://golang.org/pkg/time/#Since

https://www.socketloop.com/tutorials/golang-calculate-elapsed-run-time

Advertisement