无法在Mac系统上使用GoLang安装Beego框架。

huangapple go评论121阅读模式
英文:

Unable to install Beego framwork with GoLang on mac system

问题

我是你的中文翻译助手,以下是翻译好的内容:

我是Go Lang的新手,正在尝试在我的Mac系统上安装Beego框架。但我不确定如何安装Beego和bee工具。我参考了几个网站,但无法找到/解决实际问题。

我正在使用以下版本的GO。
go version go1.17.5 darwin/amd64

我正在尝试从这个网站安装Beego:https://beego.vip/,使用以下命令:
go get github.com/beego/beego/v2@v2.0.0

之后它下载了一些文件,但我不确定如何检查Beego是否已正确安装。

go env文件

GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/var/root/Library/Caches/go-build"
GOENV="/var/root/Library/Application Support/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOINSECURE=""
GOMODCACHE="/var/root/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="darwin"
GOPATH="/var/root/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/Cellar/go/1.17.5/libexec"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/Cellar/go/1.17.5/libexec/pkg/tool/darwin_amd64"
GOVCS=""
GOVERSION="go1.17.5"
GCCGO="gccgo"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/usr/local/go/src/go.mod"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -arch x86_64 -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build2032782=/tmp/go-build -gno-record-gcc-switches -fno-common"

我还安装了https://beego.vip/docs/install/bee.md。

但是当我执行命令bee version时,我收到错误消息sh: bee: command not found

我还读到需要设置GOPATH和GOROOT的值,但不确定如何添加这些值。

export GOPATH=
export GOROOT=

我需要在这里设置哪些值?

你能指导我吗?

英文:

I am new in Go Lang and I am trying to install Beego framework on my mac system. But I am not sure how to install Beego and bee tools. I referred couple of sites but unable to find/resolve actual issue.

I am using below version of GO.
go version go1.17.5 darwin/amd64

I am trying to install Beego from this website: https://beego.vip/ with
command: go get github.com/beego/beego/v2@v2.0.0

After this it downloaded few files but I am not sure how to check if Beego is installed properly or not.

go env file

GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/var/root/Library/Caches/go-build"
GOENV="/var/root/Library/Application Support/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOINSECURE=""
GOMODCACHE="/var/root/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="darwin"
GOPATH="/var/root/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/Cellar/go/1.17.5/libexec"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/Cellar/go/1.17.5/libexec/pkg/tool/darwin_amd64"
GOVCS=""
GOVERSION="go1.17.5"
GCCGO="gccgo"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/usr/local/go/src/go.mod"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -arch x86_64 -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build2032782=/tmp/go-build -gno-record-gcc-switches -fno-common"

I have also installed.
https://beego.vip/docs/install/bee.md

But when I am executing command like
bee version I am getting error sh: bee: command not found

I also read that I need to set GOPATH and GOROOT values but not sure how to add those values.

export GOPATH=
export GOROOT=

Which values I need to set here?

Can you please guide me here?

答案1

得分: 2

这取决于你使用的是哪个shell。你需要将变量添加到终端的配置文件中。

在我的情况下,我使用的是zsh/zshrc。

尝试以下步骤:

  • go install github.com/beego/bee/v2@latest

  • nano ~/.zshrc

  • 添加下面的行,并保存文件。

    export GOPATH="$HOME/go"
    export PATH="$GOPATH/bin:$PATH"

  • 关闭并重新打开终端

现在,你应该能够运行bee version了。

英文:

It depends on which shell you are using. You have to add the variable to the configuration file of your terminal.

In my case, I'm using zsh/zshrc.

try this:

  • go install github.com/beego/bee/v2@latest

  • nano ~/.zshrc

  • Add the lines below, and save the file.

export GOPATH="$HOME/go"
export PATH="$GOPATH/bin:$PATH"
  • Close and re-open the terminal

Now, you should be able to run bee version

huangapple
  • 本文由 发表于 2022年2月15日 18:18:48
  • 转载请务必保留本文链接:https://go.coder-hub.com/71124701.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定