golang版本切换

2022-04-10  本文已影响0人  robertzhai

背景

切换脚本

cat /usr/local/tools/go_version.sh

#!/bin/bash

## sh ~/go_version.sh 17
## sh ~/go_version.sh 13

back_file=""
if (( "$(uname)"=="Darwin"   )) ;then
      # Mac OS X 操作系统 sed 替换配置文件版本 mac 需要 需要备份源文件 "_bak"
      back_file="_bak"
elif (( "$(expr substr $(uname -s) 1 5)"=="Linux"  )) ;then
     # GNU/Linux操作系统
      back_file=""
elif ((  "$(expr substr $(uname -s) 1 10)"=="MINGW32_NT" )) ;then
     # Windows NT操作系统
      back_file=""
fi

file='/Users/admin/.bash_profile'
go17root='/usr/local/go/go17'
go13root='/usr/local/go/go13'

if (( "$1" == "17" )); then
    sed -i  "$back_file" "s#$go13root#$go17root#g" "$file"
elif (( "$1" == "13" )); then
    sed -i  "$back_file" "s#$go17root#$go13root#g" "$file"

else
    echo "invalid arg"
fi

alias

切换

gvm 切换

上一篇下一篇

猜你喜欢

热点阅读