File: README.md

package info (click to toggle)
golang-github-shurcool-gopherjslib 0.0~git20200209.30f639d-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, sid, trixie
  • size: 68 kB
  • sloc: makefile: 2
file content (55 lines) | stat: -rw-r--r-- 1,255 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
gopherjslib
===========

[![Build Status](https://travis-ci.org/shurcooL/gopherjslib.svg?branch=master)](https://travis-ci.org/shurcooL/gopherjslib) [![GoDoc](https://godoc.org/github.com/shurcooL/gopherjslib?status.svg)](https://godoc.org/github.com/shurcooL/gopherjslib)

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
------------

```bash
go get -u github.com/shurcooL/gopherjslib
```

License
-------

-	[MIT License](LICENSE)