Last active
June 23, 2023 04:21
-
-
Save TrQ-Hoan/af0b342160efb4da16506cadb5ea8358 to your computer and use it in GitHub Desktop.
Golang install on WSL
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
go mod init <module name> | |
# build linux amd64 + stripped | |
gox -osarch="linux/amd64" -ldflags "-s -w" | |
# build linux amd64 + stripped + static link | |
gox -osarch="linux/amd64" -ldflags "-s -w -linkmode 'external' -extldflags '-static'" | |
# build windows x86 + stripped | |
gox -osarch="windows/386" -ldflags "-s" | |
env GOOS=windows GOARCH=amd64 go build -ldflags="-s -w" -o <fileout.exe> <source.go> | |
env GOOS=windows GOARCH=386 go build -ldflags="-s -w" -o <fileout.exe> <source.go> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
curl https://dl.google.com/go/go1.18.10.linux-amd64.tar.gz -O | |
tar -C /usr/local -xzf go1.18.10.linux-amd64.tar.gz | |
ln -s /usr/local/go/bin/go /usr/bin/go | |
ln -s /usr/local/go/bin/gofmt /usr/bin/gofmt | |
export GOPATH=/usr/local/go | |
go install github.com/mitchellh/gox@latest | |
ln -s /usr/local/go/bin/gox /usr/bin/gox |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment