We will learnĀ about Since() function in time package in go. We will also see what is Since() function and how to use Since() function in program in go.
Since() function is used to get the time elapsed since given time. We can also say, It is shorthand for time.Now().Sub(t).
Function prototype:
func Since(t Time) Duration
Return value:
Since() function in time package returns
the time elapsed since given time i.e t.
Example with code:
package main
import (
"fmt"
"time"
)
func main() {
time.Sleep(10 * time.Millisecond)
end_time := time.Now()
elapsed := time.Since(end_time)
fmt.Println("Elapsed time: ", elapsed)
}
Output:
Elapsed time: 345ns
To learn more about golang, Please refer given below link:
https://techieindoor.com/go-lang-tutorial/
References:
https://golang.org/doc/
https://golang.org/pkg/