因為牆的原因導緻安裝bee失敗的解決辦法,總有一個适合你。
先來看兩種常見的報錯:
第一種:
$ go get -u github.com/beego/bee
# cd C:\GOPATH\src\golang.org\x\text; git pull --ff-only
fatal: unable to access 'https://go.googlesource.com/text/': Failed to connect to go.googlesource.com port 443: Timed out
package golang.org/x/text/transform: exit status 1
第二種:
$ go get github.com/beego/bee
# github.com/gadelkareem/delve/service/debugger
..\github.com\gadelkareem\delve\service\debugger\debugger.go:129:3: cannot use logger (type *"github.com/go-delve/delve/vendor/github.com/sirupsen/logrus".Entry) as type *"github.com/gadelkareem/delve/vendo
r/github.com/sirupsen/logrus".Entry in field value
# github.com/gadelkareem/delve/service/rpccommon
..\github.com\gadelkareem\delve\service\rpccommon\server.go:83:3: cannot use logger (type *"github.com/go-delve/delve/vendor/github.com/sirupsen/logrus".Entry) as type *"github.com/gadelkareem/delve/vendor/
github.com/sirupsen/logrus".Entry in field value
當然這是我安裝的時候的報錯,可能與你的報錯略有不同,但問題原因是一緻的,那就是防火牆,網上有很多種解決辦法這裡總結一下,但是我這邊環境試了都不行,最後發現了一種新的解決辦法,這裡向大家詳細介紹一下:
1. 翻牆
這裡就不詳述了,翻牆後,直接安裝官網教程安裝即可,但注意要科學上網,哈哈哈
2. 設定代理
首先更改golang的配置網上有兩種配置方法(這裡以windows系統為例):
go env -w GOPROXY=https://goproxy.io,direct
go env -w GO111MODULE=on
或者:
set GO111MODULE=on
set GOPROXY=https://goproxy.io
再次執行
go get -u github.com/beego/bee
指令,就可以安裝成功了,測試一下:
$ bee version
______
| ___ \
| |_/ / ___ ___
| ___ \ / _ \ / _ \
| |_/ /| __/| __/
\____/ \___| \___| v1.12.0
├── Beego : 1.12.2
├── GoVersion : go1.12.5
├── GOOS : windows
├── GOARCH : amd64
├── NumCPU : 8
├── GOPATH : C:\GOPATH
├── GOROOT : c:\Go
├── Compiler : gc
└── Date : Friday, 9 Oct 2020
很遺憾我并沒有安裝成功,依舊報錯。
3. 手動安裝
首先我們要知道 bee 并不是用來在項目中實作功能的庫,他是一個為了協助快速開發 beego 項目而建立的項目,通過 bee 您可以很容易的進行 beego 項目的建立、熱編譯、開發、測試、和部署,歸根結底就是一個應用程式,我們通過改應用程式管理 beego 項目,既然使用官方的安裝方式網絡不同,那麼我們就自己手動安裝,那如何安裝呢?
首先我們在 Github 上可以找到 bee 項目的源碼,我們将源碼下載下傳下來:
git clone [email protected]:beego/bee.git
源碼是通過 Go Module 進行包管理的,我們執行
go mod vendor
下載下傳依賴包,下載下傳完成後,直接編譯源碼:
go build -o bee
編譯完成之後測試一下:
$ bee version
______
| ___ \
| |_/ / ___ ___
| ___ \ / _ \ / _ \
| |_/ /| __/| __/
\____/ \___| \___| v1.12.0
├── Beego : 1.12.2
├── GoVersion : go1.12.5
├── GOOS : windows
├── GOARCH : amd64
├── NumCPU : 8
├── GOPATH : C:\GOPATH
├── GOROOT : c:\Go
├── Compiler : gc
└── Date : Friday, 9 Oct 2020
發現是可以用的,然後我們将 bee 可執行程式放到 GOPATH 目錄即可。