去安装不适用于zsh [英] Go install not working with zsh

查看:104
本文介绍了去安装不适用于zsh的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我觉得自己是个白痴,因为我之前已经在macOS和OSX上安装了它,但是由于某种原因,我看不到自己在做错什么.请帮忙!!!我创建了一个目录~/go,它将作为我的工作空间.当我从主目录运行go env时,会得到zsh: command not found: go,我知道这是由于以下文件引起的.我的配置有什么问题?

〜/.bash_profile:

export PATH=$PATH:/usr/local/go/bin

〜/.zshrc:

export PATH=$PATH:/usr/local/go/bin

解决方案

以下配置对我有用,

~/.zshrc

export GOPATH=$HOME/golang
export GOROOT=/usr/local/opt/go/libexec
export GOBIN=$GOPATH/bin
export PATH=$PATH:$GOPATH
export PATH=$PATH:$GOROOT/bin

然后您可以看到如下配置的详细信息

go env

GOARCH="amd64"
GOBIN="/Users/my-name/golang/bin"
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/my-name/golang"
GORACE=""
GOROOT="/usr/local/opt/go/libexec"
GOTOOLDIR="/usr/local/opt/go/libexec/pkg/tool/darwin_amd64"
GCCGO="gccgo"
CC="clang"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/6q/h6nchrdj49zgjfcp8wstj94r0000gn/T/go-build874871088=/tmp/go-build -gno-record-gcc-switches -fno-common"
CXX="clang++"
CGO_ENABLED="1"
PKG_CONFIG="pkg-config"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"

I feel like an idiot because I've installed this before on macOS and OSX but for some reason I can't see what I'm doing wrong. Please help!!! I've created a directory, ~/go, which will be my workspace. When I run go env from my home directory I get zsh: command not found: go and I know it's because of the following files. What is wrong in my configuration?

~/.bash_profile:

export PATH=$PATH:/usr/local/go/bin

~/.zshrc:

export PATH=$PATH:/usr/local/go/bin

解决方案

Below config is working for me,

in ~/.zshrc

export GOPATH=$HOME/golang
export GOROOT=/usr/local/opt/go/libexec
export GOBIN=$GOPATH/bin
export PATH=$PATH:$GOPATH
export PATH=$PATH:$GOROOT/bin

You can see the configured details as below then

go env

GOARCH="amd64"
GOBIN="/Users/my-name/golang/bin"
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/my-name/golang"
GORACE=""
GOROOT="/usr/local/opt/go/libexec"
GOTOOLDIR="/usr/local/opt/go/libexec/pkg/tool/darwin_amd64"
GCCGO="gccgo"
CC="clang"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/6q/h6nchrdj49zgjfcp8wstj94r0000gn/T/go-build874871088=/tmp/go-build -gno-record-gcc-switches -fno-common"
CXX="clang++"
CGO_ENABLED="1"
PKG_CONFIG="pkg-config"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"

这篇关于去安装不适用于zsh的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆