Standard library / time
time.Time.GobEncode()
Encode time for Go gob serialization; preserves the instant and offset but not monotonic readings or location name. Expected stdout: 'true\n'.
Formal Syntax & Structure
go syntaxgo
func (t Time) GobEncode() ([]byte, error)Return Value
([]byte, error)
Encode time for Go gob serialization; preserves the instant and offset but not monotonic readings or location name.
Working Example
Example Snippetgo
package main
import ( "fmt" "time")
func fixed() time.Time { return time.Date(2024, 2, 29, 12, 34, 56, 123000000, time.UTC) }func must(err error) { if err != nil { panic(err) }}func main() { data, err := fixed().GobEncode(); must(err); fmt.Println(len(data) > 0) }