gopherjs-demo

module
v0.0.0-...-3d4ee63 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 7, 2015 License: MIT

README

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

Directories

Path Synopsis
pet
js command
go command
go/db
Go implementation of user.DB interfaces
Go implementation of user.DB interfaces
js command
js/db
Contains types for implementing the DB, DBResult and DBRow interfaces using JS objects Assumes that the JS version of 'Query()' returns a matrix of rows and columns.
Contains types for implementing the DB, DBResult and DBRow interfaces using JS objects Assumes that the JS version of 'Query()' returns a matrix of rows and columns.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL