Skip to content

Instantly share code, notes, and snippets.

@ilovejs
Last active January 21, 2022 06:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ilovejs/0883f2a775847ec871252dbfe6a95b23 to your computer and use it in GitHub Desktop.
Save ilovejs/0883f2a775847ec871252dbfe6a95b23 to your computer and use it in GitHub Desktop.
# workspace
export GOPATH=$HOME/go # mkdir that one
export GOROOT=/usr/local/go # native src
export PATH=$PATH:$GOROOT/bin:$GOPATH/bin
export GO111MODULE=on
# use the network to update the named packages and dependencies
# gou https://github.com/hashicorp/nomad
function go-update() {
local in="$1"
go get -u -v "${in:8:${#in}-1}"
}
# go-get https://github.com/hashicorp/nomad
# easy paste from browser
function go-get() {
local in="$1"
go get -v "${in:8:${#in}-1}"
}
function go-run-env(){
export $(egrep -v '^#' .env | xargs)
echo ".env parsed"
go run main.go
}
// switch nexus proxy or default public one
function go-pub() {
if [[ "$GONOPROXY" = "none" ]]; then
GOPROXY=https://nexus.xxxxxxxxxxxxxxxxxxxxxx.io/repository/gonexus.dev/
GOPRIVATE=github.com/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx/prefixxxxxxxxxx-*
GONOPROXY=$GOPROXY # not download from priv (default)
echo "turn on private";
else
GOPROXY=none
GOPRIVATE=none
GONOPROXY=none
go env -w GOPRIVATE=""
go env -w GOPROXY=""
echo "turn off private"
fi
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment