mirror of
https://github.com/linuxkit/linuxkit.git
synced 2025-09-01 23:18:41 +00:00
Add go-compile script to linuxkit/alpine
This means Go code can use the same base image, which now includes Go tooling. Signed-off-by: Justin Cormack <justin.cormack@docker.com>
This commit is contained in:
46
tools/alpine/go-compile.sh
Executable file
46
tools/alpine/go-compile.sh
Executable file
@@ -0,0 +1,46 @@
|
||||
#!/bin/sh
|
||||
|
||||
set -e
|
||||
|
||||
usage() {
|
||||
echo "Usage: dir"
|
||||
exit 1
|
||||
}
|
||||
|
||||
[ $# = 0 ] && usage
|
||||
|
||||
dir="$1"
|
||||
|
||||
cd "$dir"
|
||||
|
||||
# lint before building
|
||||
>&2 echo "gofmt..."
|
||||
test -z $(gofmt -s -l .| grep -v .pb. | grep -v vendor/ | tee /dev/stderr)
|
||||
|
||||
>&2 echo "govet..."
|
||||
test -z $(GOOS=linux go tool vet -printf=false . 2>&1 | grep -v vendor/ | tee /dev/stderr)
|
||||
|
||||
>&2 echo "golint..."
|
||||
test -z $(find . -type f -name "*.go" -not -path "*/vendor/*" -not -name "*.pb.*" -exec golint {} \; | tee /dev/stderr)
|
||||
|
||||
>&2 echo "ineffassign..."
|
||||
test -z $(find . -type f -name "*.go" -not -path "*/vendor/*" -not -name "*.pb.*" -exec ineffassign {} \; | tee /dev/stderr)
|
||||
|
||||
>&2 echo "go test..."
|
||||
go test
|
||||
|
||||
>&2 echo "go build..."
|
||||
|
||||
export CGO_ENABLED=0
|
||||
|
||||
if [ "$GOOS" = "darwin" -o "$GOOS" = "windows" ]
|
||||
then
|
||||
if [ -z "$ldflags" ]
|
||||
then
|
||||
go install
|
||||
else
|
||||
go install -ldflags "${ldflags}"
|
||||
fi
|
||||
else
|
||||
go install -buildmode pie -ldflags "-s -w ${ldflags} -extldflags \"-fno-PIC -static\""
|
||||
fi
|
Reference in New Issue
Block a user