github.com/gopherjs/gopherjs@v1.19.0-beta1.0.20240506212314-27071a8796e4/tests/testdata/time_inexternalization.go (about) 1 package main 2 3 import ( 4 "time" 5 6 "github.com/gopherjs/gopherjs/js" 7 ) 8 9 var _ = time.Sleep // Force "time" package to be imported but let time.Time and time.Unix be DCEed since they're not used. 10 11 func main() { 12 // Exercise externalization of Go struct (with its special handling of time.Time). 13 js.Global.Get("console").Call("log", struct{ S string }{"externalization ok"}) 14 15 // Exercise internalization of JavaScript Date object (with its special handling of time.Time). 16 date := js.Global.Get("Date").New("2015-08-29T20:56:00.869Z").Interface() 17 js.Global.Set("myDate", date) 18 js.Global.Get("console").Call("log", js.Global.Get("myDate").Call("toUTCString")) 19 }