Golang time.ParseDuration() function example
package time
Golang time.ParseDuration() function usage example
package main
import (
"fmt"
"time"
)
func main() {
dura, err := time.ParseDuration("10ns")
if err != nil {
fmt.Println(err)
}
fmt.Println(dura)
dura, err = time.ParseDuration("1h2m3s4ms5us6ns")
if err != nil {
fmt.Println(err)
}
fmt.Println(dura)
}
Output :
10ns
1h2m3.004005006s
Reference :
Advertisement
Something interesting
Tutorials
+21.1k Golang : Get password from console input without echo or masked
+5.8k Unix/Linux : How to test user agents blocked successfully ?
+5.4k Golang : Intercept, inject and replay HTTP traffics from web server
+15.9k Golang : Update database with GORM example
+14.1k Golang : Check if a file exist or not
+7.1k Javascript : How to get JSON data from another website with JQuery or Ajax ?
+22.1k Golang : Print leading(padding) zero or spaces in fmt.Printf?
+10.2k Golang : Use regular expression to get all upper case or lower case characters example
+19k Golang : Padding data for encryption and un-padding data for decryption
+5.3k Golang : Pad file extension automagically
+5.4k Golang : Return multiple values from function
+16k Golang : How to reverse elements order in map ?