Skip to content

Commit 381a079

Browse files
committed
playground: use Go 1.12
Go 1.12 has been released¹ and should be used, so that it's possible to play with Go programs that rely on Go 1.12-only features. In Go 1.12, build cache is required. Either GOCACHE must be set, or HOME must be set so that GOCACHE can be implicitly deduced. Set HOME and pass it on to the go build invocation inside the compileAndRun function. This fixes the following error, detected by the playground test: 2019/02/26 06:28:44 compile error: build cache is required, but could not be located: GOCACHE is not defined and neither $XDG_CACHE_HOME nor $HOME are defined The command '/bin/sh -c /app/playground test' returned a non-zero code: 1 This is related to issues golang/go#29243 and golang/go#29251, and the fix in CL 154181. ¹ https://groups.google.com/d/msg/golang-announce/Y1RZqnCKUKY/N9yK5c8iBgAJ Fixes golang/go#30397 Change-Id: I44c5c8928060732f31fd935b114568258c7298c7 Reviewed-on: https://go-review.googlesource.com/c/163798 Reviewed-by: Brad Fitzpatrick <[email protected]>
1 parent e08a6e0 commit 381a079

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

Dockerfile

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ ENV GOPATH /go
88
ENV PATH /usr/local/go/bin:$GOPATH/bin:$PATH
99
ENV GOROOT_BOOTSTRAP /usr/local/gobootstrap
1010
ENV CGO_ENABLED=0
11-
ENV GO_VERSION 1.11.1
11+
ENV GO_VERSION 1.12
1212
ENV BUILD_DEPS 'curl bzip2 git gcc patch libc6-dev ca-certificates'
1313

1414
# Fake time
@@ -174,6 +174,10 @@ RUN apt-get update && apt-get install -y git ca-certificates --no-install-recomm
174174
COPY --from=builder /usr/local/go /usr/local/go
175175
COPY --from=builder /tmp/sel_ldr_x86_64 /usr/local/bin
176176

177+
# For implicit GOCACHE (issues 29243 and 29251), set HOME:
178+
RUN mkdir -p /home/gopher
179+
ENV HOME /home/gopher
180+
177181
ENV GOPATH /go
178182
ENV PATH /usr/local/go/bin:$GOPATH/bin:$PATH
179183

sandbox.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,7 @@ func compileAndRun(req *request) (*response, error) {
324324

325325
exe := filepath.Join(tmpDir, "a.out")
326326
cmd := exec.Command("go", "build", "-o", exe, in)
327-
cmd.Env = []string{"GOOS=nacl", "GOARCH=amd64p32", "GOPATH=" + os.Getenv("GOPATH")}
327+
cmd.Env = []string{"GOOS=nacl", "GOARCH=amd64p32", "GOPATH=" + os.Getenv("GOPATH"), "HOME=" + os.Getenv("HOME")}
328328
if out, err := cmd.CombinedOutput(); err != nil {
329329
if _, ok := err.(*exec.ExitError); ok {
330330
// Return compile errors to the user.

0 commit comments

Comments
 (0)