Use Go 1.10.3 which includes minimal module support for vgo transition:
$ cd /tmp
$ curl -s https://dl.google.com/go/go1.10.3.linux-amd64.tar.gz | tar -zx
$ export PATH=/tmp/go/bin:$PATH
$ which go
/tmp/go/bin/go
$ go version
go build -o main -tags main && go build -o main2 -tags main2 | |
# run main2 by itself | |
./main2 | |
# exits with a non-zero exit code and gives: | |
# | |
# 1st line to stdout | |
# 2nd line to stderr | |
# 3rd line to stdout |
$ cd $GOROOT/src | |
$ grep -h -r '^[ \t]*//go:' | sort | uniq | |
//go:a | |
//go:b | |
//go:c1 | |
//go:c2 | |
//go:cgo_dynamic_linker "<path>" | |
//go:cgo_export_dynamic _cgo_panic | |
//go:cgo_export_dynamic _cgo_topofstack | |
//go:cgo_export_dynamic crosscall2 |
// this program demonstrates how fetches through gopherjs seem to be memory leaking. | |
package main | |
import ( | |
"fmt" | |
"io" | |
"io/ioutil" | |
"log" | |
"net/http" |
Use Go 1.10.3 which includes minimal module support for vgo transition:
$ cd /tmp
$ curl -s https://dl.google.com/go/go1.10.3.linux-amd64.tar.gz | tar -zx
$ export PATH=/tmp/go/bin:$PATH
$ which go
/tmp/go/bin/go
$ go version
package main | |
import ( | |
"bufio" | |
"fmt" | |
"io" | |
"os" | |
"os/exec" | |
"time" | |
) |
vgo: finding github.com/moby/moby v17.03.2-ce | |
vgo: finding github.com/RackSec/srslog 456df3a81436d29ba874f3590eeeee25d666f8a5 | |
vgo: finding github.com/vdemeester/shakers 24d7f1d6a71aa5d9cbe7390e4afb66b7eef9e1b3 | |
vgo: finding github.com/vishvananda/netns 604eaf189ee867d8c147fafc28def2394e878d25 | |
vgo: finding github.com/aws/aws-sdk-go v1.4.22 | |
vgo: finding github.com/docker/docker-credential-helpers f72c04f1d8e71959a6d103f808c50ccbad79b9fd | |
vgo: finding github.com/docker/go-connections ecb4cb2dd420ada7df7f2593d6c25441f65f69f2 | |
vgo: finding github.com/docker/distribution 28602af35aceda2f8d571bad7ca37a54cf0250bc | |
vgo: finding github.com/fsnotify/fsnotify v1.2.11 | |
vgo: finding golang.org/x/time a4bde12657593d5e90d0533a3e4fd95e635124cb |
GopherJS is a compiler from Go to JavaScript that targets browser VMs.
The package github.com/gopherjs/gopherjs
is the compiler program, responsible for transpiling Go code to JavaScript.
The package github.com/gopherjs/gopherjs/js
provides an API for
interacting with native JavaScript.
Because of the limited runtime environment afforded by a JavaScript VM (especially in the browser), GopherJS provides
$ export GOPATH=/tmp/tmp.INWBhiKAgt | |
$ cd /tmp/tmp.eoCQw0fOCT | |
$ mkdir hello | |
$ cd hello | |
$ export GOBIN=/tmp/tmp.opPK4KUGiw/hello/.bin | |
$ export PATH=/tmp/tmp.opPK4KUGiw/hello/.bin:/root/bin:/go/bin:/usr/local/go/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin | |
$ go mod init example.com/hello | |
go: creating new go.mod: module example.com/hello | |
$ echo "package main" >pkg.go | |
$ go get github.com/ianthehat/[email protected] |
export GOPATH=$(mktemp -d) | |
cd $GOPATH | |
mkdir -p src/example.com/hello | |
cd src/example.com/hello | |
export GOBIN=$PWD/.bin | |
export PATH=$GOBIN:$PATH | |
echo "package main" > pkg.go | |
go get github.com/mdempsky/gocode | |
pushd $(go list -f "{{.Dir}}" github.com/mdempsky/gocode) | |
git checkout 00e7f5ac290aeb20a3d8d31e737ae560a191a1d5 |