Skip to content

Instantly share code, notes, and snippets.

@goofmint
Created December 12, 2018 01:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save goofmint/cd05ddc7cacd1ab10c1fef60cde45910 to your computer and use it in GitHub Desktop.
Save goofmint/cd05ddc7cacd1ab10c1fef60cde45910 to your computer and use it in GitHub Desktop.
func main() {
window := js.Global().Get("window")
navigator := js.Global().Get("navigator")
cb1 := js.NewCallback(func(args []js.Value) {
if navigator.Get("onLine").Bool() {
println("Network is Online");
} else {
println("Network is Offline");
}
})
window.Call("addEventListener", "online", cb1)
window.Call("addEventListener", "offline", cb1)
<-make(chan struct{}, 0)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment