We will learn about Until() function in time package in go. We will also see what is Until() function and how to use Until() function in program in go.
Until() function is used to get the duration until t given time. We can also say, It is shorthand for t.Sub(time.Now()).
Function prototype:
Return value:
Until() function in time package returns the duration until until given time i.e t .
Example with code:
package main
import (
"fmt"
"time"
)
func main() {
time.Sleep(10 * time.Millisecond)
curr_time := time.Now()
elapsed := time.Until(curr_time)
fmt.Println("Elapsed time: ", elapsed)
}
Output:
Elapsed time: -585ns
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/