Skip to content

A demo project showing how to use GopherJS to share Go code between Go and JS applications

License

Notifications You must be signed in to change notification settings

rolaveric/gopherjs-demo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

gopherjs-demo

A demo project showing how to use GopherJS to share Go code between Go and JS applications

Setup

Install gopherjs as a command line tool

go get -u github.com/gopherjs/gopherjs

pet

A simple example of a Go struct being exported for use in JS code.

cd pet/js
gopherjs build main.go  
node index.js

user

A more complex example of a Go library that could be reused between Go and JS applications.

Note that, for brevity's sake, the user example does not include as much type checking as it should. For example, RegisterDBJS(jsdb) should check that jsdb really does include a Query() function.

To test in Go:

cd user/go
go run main.go

To test in NodeJS:

cd user/js
gopherjs build main.go
node index.js

About

A demo project showing how to use GopherJS to share Go code between Go and JS applications

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published