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

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

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文件

  1. GO111MODULE=""
  2. GOARCH="amd64"
  3. GOBIN=""
  4. GOCACHE="/var/root/Library/Caches/go-build"
  5. GOENV="/var/root/Library/Application Support/go/env"
  6. GOEXE=""
  7. GOEXPERIMENT=""
  8. GOFLAGS=""
  9. GOHOSTARCH="amd64"
  10. GOHOSTOS="darwin"
  11. GOINSECURE=""
  12. GOMODCACHE="/var/root/go/pkg/mod"
  13. GONOPROXY=""
  14. GONOSUMDB=""
  15. GOOS="darwin"
  16. GOPATH="/var/root/go"
  17. GOPRIVATE=""
  18. GOPROXY="https://proxy.golang.org,direct"
  19. GOROOT="/usr/local/Cellar/go/1.17.5/libexec"
  20. GOSUMDB="sum.golang.org"
  21. GOTMPDIR=""
  22. GOTOOLDIR="/usr/local/Cellar/go/1.17.5/libexec/pkg/tool/darwin_amd64"
  23. GOVCS=""
  24. GOVERSION="go1.17.5"
  25. GCCGO="gccgo"
  26. AR="ar"
  27. CC="clang"
  28. CXX="clang++"
  29. CGO_ENABLED="1"
  30. GOMOD="/usr/local/go/src/go.mod"
  31. CGO_CFLAGS="-g -O2"
  32. CGO_CPPFLAGS=""
  33. CGO_CXXFLAGS="-g -O2"
  34. CGO_FFLAGS="-g -O2"
  35. CGO_LDFLAGS="-g -O2"
  36. PKG_CONFIG="pkg-config"
  37. 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的值,但不确定如何添加这些值。

  1. export GOPATH=
  2. 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

  1. GO111MODULE=""
  2. GOARCH="amd64"
  3. GOBIN=""
  4. GOCACHE="/var/root/Library/Caches/go-build"
  5. GOENV="/var/root/Library/Application Support/go/env"
  6. GOEXE=""
  7. GOEXPERIMENT=""
  8. GOFLAGS=""
  9. GOHOSTARCH="amd64"
  10. GOHOSTOS="darwin"
  11. GOINSECURE=""
  12. GOMODCACHE="/var/root/go/pkg/mod"
  13. GONOPROXY=""
  14. GONOSUMDB=""
  15. GOOS="darwin"
  16. GOPATH="/var/root/go"
  17. GOPRIVATE=""
  18. GOPROXY="https://proxy.golang.org,direct"
  19. GOROOT="/usr/local/Cellar/go/1.17.5/libexec"
  20. GOSUMDB="sum.golang.org"
  21. GOTMPDIR=""
  22. GOTOOLDIR="/usr/local/Cellar/go/1.17.5/libexec/pkg/tool/darwin_amd64"
  23. GOVCS=""
  24. GOVERSION="go1.17.5"
  25. GCCGO="gccgo"
  26. AR="ar"
  27. CC="clang"
  28. CXX="clang++"
  29. CGO_ENABLED="1"
  30. GOMOD="/usr/local/go/src/go.mod"
  31. CGO_CFLAGS="-g -O2"
  32. CGO_CPPFLAGS=""
  33. CGO_CXXFLAGS="-g -O2"
  34. CGO_FFLAGS="-g -O2"
  35. CGO_LDFLAGS="-g -O2"
  36. PKG_CONFIG="pkg-config"
  37. 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.

  1. export GOPATH=
  2. 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.

  1. export GOPATH="$HOME/go"
  2. 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:

确定