大约10天前,我在Ubuntu 18.04.01 Server Edition中安装了golang:
go version
go version go1.10.4 linux/amd64
.bashrc中设置的GOPATH是这样的:
export GOPATH=$HOME/go
export PATH=${PATH}:${GOPATH}/bin
从那时起我一直在使用golang。 今天,我尝试安装beego,但发生了一件非常奇怪的事情:
go get -u github.com/astaxie/beego
go get -u github.com/beego/bee
二进制文件安装在非常长且实际上是奇怪且荒谬的路径中:
marco@pc01:~/go/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:
/sbin:/bin:/usr/games:/usr/local/games:/snap/bin$ ls -lah
total 16M
drwxrwxr-x 2 marco marco 4.0K Jan 30 17:14 .
drwxrwxr-x 3 marco marco 4.0K Jan 30 17:14 ..
-rwxrwxr-x 1 marco marco 16M Jan 30 17:14 bee
src beego目录似乎已正确安装:
/home/marco/go/src/github.com/beego/bee
再次奇怪的是,如果尝试执行以下简单的go代码:
package main
import (
"github.com/astaxie/beego"
)
type MainController struct {
beego.Controller
}
func (this *MainController) Get() {
this.Ctx.WriteString("hello world")
}
func main() {
beego.Router("/", &MainController{})
beego.Run()
}
go run helloBeego.go
2019/01/30 17:37:06.139 [I] http server Running on http://:8080
在Web浏览器中,我实际上得到了:
hello world
但是当我尝试创建一个蜜蜂项目时:
/go/src$ bee new my-first-beego-project
Command 'bee' not found, did you mean:
command 'be' from deb bugs-everywhere
command 'btee' from deb ruby-bcat
command 'beef' from deb beef
command 'bbe' from deb bbe
command 'ben' from deb ben
command 'beet' from deb beets
command 'beep' from deb beep
command 'see' from deb mime-support
command 'ree' from deb ree
command 'pee' from deb moreutils
command 'beer' from deb gerstensaft
command 'tee' from deb coreutils
command 'bel' from deb belier
我猜想,将蜜蜂二进制文件放入其中的荒谬路径以及使用“ bee new”命令创建蜜蜂项目失败的事实是相关的问题。 如何解决? 期待您的帮助。 马可
根据正确要求添加了信息:
marco@pc01:~$ go env
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/marco/.cache/go-build"
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/marco/go"
GORACE=""
GOROOT="/usr/lib/go-1.10"
GOTMPDIR=""
GOTOOLDIR="/usr/lib/go-1.10/pkg/tool/linux_amd64"
GCCGO="gccgo"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-
map=/tmp/go-build461259545=/tmp/go-build -gno-record-gcc-switches"
marco@pc01:~$
beego版本:
v1.6.2