Skip to content

Commit

Permalink
update go setting
Browse files Browse the repository at this point in the history
  • Loading branch information
zy9306 committed Oct 25, 2023
1 parent b0735d2 commit 63cbf3e
Showing 1 changed file with 29 additions and 11 deletions.
40 changes: 29 additions & 11 deletions dotfiles/zsh/.env
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# -*- mode: sh -*-

path_remove() {
# only work in zsh
path=("${(@)path:#"$1"}")
}

prepend_path() {
APPEND_PATH=$1
if [ -d $APPEND_PATH ]; then
Expand Down Expand Up @@ -93,19 +98,32 @@ if [[ $(command_exists virtualenvwrapper.sh) == true ]]; then
fi

# Go
if [ -d "/usr/local/go/bin" ]; then
APPEND_PATH="/usr/local/go/bin"
if [[ $PATH != *"$APPEND_PATH"* ]]; then
export PATH=$APPEND_PATH:$PATH
fi
fi
go-arm64() {
mkdir -p $HOME/go-arm64/go
export GOPATH=$HOME/go-arm64/go
export GOROOT="/usr/local/go-arm64/go"
go env -w GOPATH=$GOPATH GOROOT=$GOROOT
mkdir -p "$GOROOT/bin" "$GOPATH/bin"
path_remove "$GOROOT/bin"
path_remove "$GOPATH/bin"
prepend_path "$GOROOT/bin"
prepend_path "$GOPATH/bin"
}

go-amd64() {
mkdir -p $HOME/go-amd64/go
export GOPATH=$HOME/go-amd64/go
export GOROOT="/usr/local/go-amd64/go"
go env -w GOPATH=$GOPATH GOROOT=$GOROOT
mkdir -p "$GOROOT/bin" "$GOPATH/bin"
path_remove "$GOROOT/bin"
path_remove "$GOPATH/bin"
prepend_path "$GOROOT/bin"
prepend_path "$GOPATH/bin"
}

if [[ $(command_exists go) == true ]]; then
export GOPATH=~/go
APPEND_PATH="$GOPATH/bin"
if [[ $PATH != *"$APPEND_PATH"* ]]; then
export PATH=$APPEND_PATH:$PATH
fi
go-arm64
fi

# Rust
Expand Down

0 comments on commit 63cbf3e

Please sign in to comment.