functiongouse() { if [[ $# -eq 0 ]] then echo"usage $FUNCNAME <go version(1.12,1.13,1.14,...)>" return fi local USER_LOCAL_DIR=/usr/local local targetGoVersion=$1 local choice for GoVersion in${USER_LOCAL_DIR}/go1.1* do if [[ ${GoVersion} =~ ${targetGoVersion} ]] then read -p "Shall I use ${GoVersion}? (y/Y | n/N) " -t 5 choice choice=$(echo$choice | tr 'A-Z''a-z') if [[ ${choice:0:1} == "y" ]] then sudo rm -rf ${USER_LOCAL_DIR}/go sudo ln -sf ${GoVersion}${USER_LOCAL_DIR}/go return fi echo fi done echo"${targetGoVersion} not found in ${USER_LOCAL_DIR}" }