Skip to content

Commit 382e053

Browse files
committed
Improve update.sh script to not hardcode GOROOT.
Do not hardcode /usr/local/go path for GOROOT, instead use `go env GOROOT`. It will return the default GOROOT if GOROOT env var is not set. Use $() instead of backticks because apparently it's the recommended style.
1 parent 1db5d32 commit 382e053

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

playground/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ A secondary motivation is making the playground usable for other projects, such
66

77
## Development
88

9-
To update the entire playground environment (which currently requires your Go installation to located exactly at `/usr/local/go`), just run `go generate github.com/gopherjs/gopherjs.github.io/playground`. It will install your local version of GopherJS compiler, build the playground, make a temporary copy of Go from /usr/local/go to /tmp/gopherjsplayground_goroot, rebuild and copy the standard library into the `pkg` directory.
9+
To update the entire playground environment, just run `go generate github.com/gopherjs/gopherjs.github.io/playground`. It will install your local version of GopherJS compiler, build the playground, make a temporary copy of Go to /tmp/gopherjsplayground_goroot, rebuild and copy the standard library into the `pkg` directory.
1010

1111
Working on the playground application itself is made easier by using the `gopherjs serve` command to rebuild and serve the playground every time you refresh the browser.
1212

playground/update.sh

+4-4
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ go generate github.com/gopherjs/gopherjs.github.io/playground/internal/imports
99
gopherjs build -m
1010

1111
# The GOPATH workspace where the GopherJS project is.
12-
GOPHERJSGOPATH=`go list -f '{{.Root}}' github.com/gopherjs/gopherjs`
12+
GOPHERJSGOPATH=$(go list -f '{{.Root}}' github.com/gopherjs/gopherjs)
1313

1414
PKG=pkg
1515
rm -r $PKG
@@ -25,9 +25,9 @@ mkdir -p $PKG/github.com/gopherjs/gopherjs
2525
cp $GOPATH/pkg/darwin_js_min/github.com/gopherjs/gopherjs/js.a $PKG/github.com/gopherjs/gopherjs/js.a
2626
cp $GOPATH/pkg/darwin_js_min/github.com/gopherjs/gopherjs/nosync.a $PKG/github.com/gopherjs/gopherjs/nosync.a
2727

28-
# Make a copy of /usr/local/go that is user-writeable,
28+
# Make a copy of GOROOT that is user-writeable,
2929
# use it to build and copy out standard library packages.
30-
cp -r /usr/local/go /tmp/gopherjsplayground_goroot
30+
cp -r $(go env GOROOT) /tmp/gopherjsplayground_goroot
3131
export GOROOT=/tmp/gopherjsplayground_goroot
3232
gopherjs install -m archive/tar archive/zip bufio bytes compress/bzip2 compress/flate compress/gzip compress/lzw compress/zlib container/heap container/list container/ring crypto/aes crypto/cipher crypto/des crypto/dsa crypto/ecdsa crypto/elliptic crypto/hmac crypto/md5 crypto/rand crypto/rc4 crypto/rsa crypto/sha1 crypto/sha256 crypto/sha512 crypto/subtle database/sql/driver debug/gosym debug/pe encoding/ascii85 encoding/asn1 encoding/base32 encoding/base64 encoding/binary encoding/csv encoding/gob encoding/hex encoding/json encoding/pem encoding/xml errors fmt go/ast go/doc go/format go/printer go/token hash/adler32 hash/crc32 hash/crc64 hash/fnv html html/template image image/color image/draw image/gif image/jpeg image/png index/suffixarray io io/ioutil math math/big math/cmplx math/rand mime net/http/cookiejar net/http/fcgi net/http/httptest net/http/httputil net/mail net/smtp net/textproto net/url path path/filepath reflect regexp regexp/syntax runtime/internal/sys sort strconv strings sync/atomic testing testing/iotest testing/quick text/scanner text/tabwriter text/template text/template/parse time unicode unicode/utf16 unicode/utf8
3333
cp -r $GOROOT/pkg/darwin_js_min/* $PKG
@@ -36,4 +36,4 @@ cp -r $GOROOT/pkg/darwin_amd64_js_min/* $PKG
3636
rm -r /tmp/gopherjsplayground_goroot
3737
rm -r /tmp/gopherjsplayground_gopath
3838

39-
rename 's/\.a/\.a.js/' `find $PKG -name "*.a"`
39+
rename 's/\.a/\.a.js/' $(find $PKG -name "*.a")

0 commit comments

Comments
 (0)