Standard library / encoding
encoding.TextUnmarshaler
Interface for decoding text. Retained input must be copied; formats and error rules depend on the implementation. Expected stdout: '0\n'.
Formal Syntax & Structure
go syntaxgo
type TextUnmarshaler interface { UnmarshalText(text []byte) error}Working Example
Example Snippetgo
package main
import ( "encoding" "fmt" "time")
func must(e error) { if e != nil { panic(e) }}
func main() { var t time.Time var x encoding.TextUnmarshaler = &t must(x.UnmarshalText([]byte("1970-01-01T00:00:00Z"))) fmt.Println(t.Unix())}