The Central Go Modules Repository

To use GoCenter:
export GOPROXY=https://gocenter.io
3
Stars
MIT
License
35,898
Downloads
February 9th 2020
Last Modified
Version:
Loading...

gopherjslib

Build Status GoDoc

Package gopherjslib provides helpers for in-process GopherJS compilation.

All of them take the optional *Options argument. It can be used to set a different GOROOT or GOPATH directory or to enable minification.

Example compiling Go code:

import "github.com/shurcooL/gopherjslib"

...

code := strings.NewReader(`
	package main
	import "github.com/gopherjs/gopherjs/js"
	func main() { println(js.Global.Get("window")) }
`)

var out bytes.Buffer

err := gopherjslib.Build(code, &out, nil) // <- default options

Example compiling multiple files:

var out bytes.Buffer

builder := gopherjslib.NewBuilder(&out, nil)

fileA := strings.NewReader(`
	package main
	import "github.com/gopherjs/gopherjs/js"
	func a() { println(js.Global.Get("window")) }
`)

builder.Add("a.go", fileA)

// And so on for each file, then:

err = builder.Build()

Installation

go get -u github.com/shurcooL/gopherjslib

License

  • MIT License