由于网上安装beego和bee的方法大多都是这样的:
go get -u github.com/astaxie/beego
go get -u github.com/beego/bee
但是会因不能访问外网安装出错,所以有如下方法:
首先按照正常安装go的方式安装好go环境
在
https://github.com/astaxie/beego
https://github.com/beego/bee
下载好这俩文件夹:beego和bee
在安装的go配置的GOPATH目录下新建好如下路径:你的gopath路径\src\github.com\astaxie
,粘贴
beego文件夹
在你的gopath路径\src\github.com\beego
粘贴bee文件夹
打开cmd,切到你的gopath路径\src\github.com\beego\bee
目录下,执行go build
要是报这样的错误:
go: github.com/beego/beego/v2@v2.0.1: Get "https://proxy.golang.org/github.com/beego/beego/v2/@v/v2.0.1.mod": dial tcp 172.217.160.81:443: connectex: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.
执行一下go env -w GOPROXY=https://goproxy.cn
再执行go build
完成后会在你的gopath路径\src\github.com\beego\bee
目录下生成bee.exe文件,
新建你的gopath路径\bin
将bee.exe复制过来
再在电脑的环境变量Path中追加%GOPATH%\bin
好了,重启cmd输入bee version
C:\Users\WorkLCJ>bee version
______
| ___ \
| |_/ / ___ ___
| ___ \ / _ \ / _ \
| |_/ /| __/| __/
\____/ \___| \___| v2.0.1
├── Beego : Beego is not installed. Please do consider installing it first: https://github.com/beego/beego/v2. If you are using go mod, and you don't install the beego under $GOPATH/src/github.com/astaxie, just ignore this.
├── GoVersion : go1.14.13
├── GOOS : windows
├── GOARCH : amd64
├── NumCPU : 8
├── GOPATH : D:\Users\go
├── GOROOT : C:\Program Files\GO
├── Compiler : gc
└── Date : Monday, 14 Dec 2020
看到这个便是完成了beego和bee安装
分隔线
linux下安装beego
下载go:
wget https://golang.google.cn/dl/go1.15.6.linux-amd64.tar.gz
解压至/usr/local目录:
tar -C /usr/local -xzf go1.15.6.linux-amd64.tar.gz
配置环境变量:
vim /etc/profile
,添加:
export GOROOT=/usr/local/go
export GOPATH=$HOME/go
export PATH=$PATH:$GOROOT/bin:$GOPATH/bin
source /etc/profile
,使修改生效
安装beego:
go get -v github.com/astaxie/beego
设置GOPROXY:
export GOPROXY=https://goproxy.io
export GO111MODULE=on
可成功安装:
go get -v github.com/beego/bee
执行:bee version
可看到: