Description
Please answer these questions before submitting your issue. Thanks!
What version of Go are you using (go version
)?
Go 1.7.4
What operating system and processor architecture are you using (go env
)?
$ uname -a
Linux alexellis 4.4.19-v7+ #906 SMP Tue Aug 23 15:53:06 BST 2016 armv7l GNU/Linux
What did you do?
If possible, provide a recipe for reproducing the error.
A complete runnable program is good.
A link on play.golang.org is best.
The Go binary for ARM is built against libc instead of as a static binary, so when I try to run the Go binary on an Alpine Linux system I get an error (below)
I put together a Dockerfile which reproduces the issue on an ARMv6/7 board such as an RPi 2/3 - the below Dockerfile is +/- the same as the Official Docker golang image with the base image changed to an ARM compatible layer.
FROM armhf/alpine:latest
WORKDIR /root/
RUN mkdir -p /usr/local/go
RUN apk add --update libarchive-tools ca-certificates curl
ENV GOLANG_VERSION 1.7.4
ENV GOLANG_DOWNLOAD_URL https://golang.org/dl/go$GOLANG_VERSION.linux-armv6l.tar.gz
ENV GOLANG_DOWNLOAD_SHA256 075c5f4446234e26c1380003ff2b050f0c7e63591410bab65355a945601bf245
RUN curl -fsSL "$GOLANG_DOWNLOAD_URL" -o golang.tar.gz \
&& sha256sum golang.tar.gz \
&& echo "$GOLANG_DOWNLOAD_SHA256 golang.tar.gz" | sha256sum -c - \
&& bsdtar -C /usr/local -xzf golang.tar.gz \
&& rm golang.tar.gz
ENV GOPATH /go
ENV PATH $GOPATH/bin:/usr/local/go/bin:$PATH
RUN mkdir -p "$GOPATH/src" "$GOPATH/bin" && chmod -R 777 "$GOPATH"
WORKDIR $GOPATH
CMD ["go"]
What did you expect to see?
Go to function the same way as when I download the binary to a Debian-based system (which includes libc).
Having spoken to @justincormack from Docker we thought it would be good to have a statically-linked binary available so that using Golang on Alpine Linux does not need a complete re-build against musl.
What did you see instead?
/go # /usr/local/go/bin/go
go godoc gofmt
/go # /usr/local/go/bin/go
sh: /usr/local/go/bin/go: not found