In Go language, time packages supplies functionality for determining as well as viewing time. The Microseconds() function in Go language is used to find the duration of time in form of an integer microsecond count. Moreover, this function is defined under the time package. Here, you need to import the “time” package in order to use these functions.
Syntax:
func (d Duration) Microseconds() int64
Here, d is the duration of time.
Return Value: It returns the duration value as int64.
Example 1:
// Golang program to illustrate the usage of // Microseconds() function // Including main package package main // Importing fmt and time import ( "fmt"
"time"
) // Calling main func main() { // Defining duration
// of Microseconds method
micr, _ := time .ParseDuration( "5m" )
// Prints duration as
// an integer microsecond
fmt.Printf( "Only %d Microseconds of task " +
"is remaining." , micr.Microseconds())
} |
Output:
Only 300000000 Microseconds of task is remaining.
Example 2:
// Golang program to illustrate the usage of // Microseconds() function // Including main package package main // Importing fmt and time import ( "fmt"
"time"
) // Calling main func main() { // Defining duration of Microseconds method
micr, _ := time .ParseDuration( "1m1s576ms46ns" )
// Prints duration as
// an integer microsecond
fmt.Printf( "Only %d Microseconds of " +
"task is remaining." , micr.Microseconds())
} |
Output:
Only 61576000 Microseconds of task is remaining.
Article Tags :