package main import ( "fmt" "time" ) func main() { t := time.Now() ns := t.Nanosecond() fmt.Printf("The current time's nanosecond component is %d\n", ns) }
package main import ( "fmt" "time" ) func main() { t := time.Date(2022, time.June, 15, 12, 30, 0, 0, time.UTC) ns := t.Nanosecond() fmt.Printf("The specified time's nanosecond component is %d\n", ns) }This code creates a `time.Time` struct for June 15, 2022 at 12:30pm UTC and then prints its nanosecond component. The package library is the standard `time` package in Go.