记录报错
1、yarn未找到
解决办法:未安装yarn依赖包
sudo apt-get install npm
npm install -g yarn
成功查看安装的版本号
2、yarn build构建项目报错
wtt@ubuntu:~/Desktop/PilotGo-plugin-topology$ go build -mod=vendor -o topoagent agent/main.go agent/main.go:11:5: //go:build comment without // +build comment agent/collector/psutil_collector.go:9:2: //go:build comment without // +build comment agent/service/container/container.go:9:2: //go:build comment without // +build comment vendor/gitee.com/openeuler/PilotGo/sdk/response/response.go:6:2: //go:build comment without // +build comment vendor/github.com/tklauser/numcpus/numcpus_linux.go:24:2: //go:build comment without // +build comment
解决办法:
这是因为go版本太低,Go 1.16版本不支持新的//go:build
构建注释标记,它是在Go 1.17中引入的,所以需要升级版本或者加入
// +build linux
// +build linux
显然这种方法太死板了,直接升级go版本到1.20,1.18在build时还是会报错。
删除go环境重新下载
sudo apt-get purge golang//包管理器
或者二进制文件安装的Go,需要手动删除Go的安装目录
sudo rm -rf /usr/local/go
重新下载
wget https://golang.org/dl/go1.20.linux-amd64.tar.gz
tar -xzf go1.20.linux-amd64.tar.gz
将go可以mv到/usr/local/目录下,并配置环境变量
sudo mv go /usr/local/
export PATH=$PATH:/usr/local/go/bin
重新bulid,显示成功
3、go build -mod=vendor -o tt agent/main.go
报错 named files must be .go files: tt
解决方法:
表明 go build
命令中包含了一个不正确的文件名或参数。Go 编译器期望接收到 .go
文件作为输入,但传递了一个非 .go
文件名 tt
。
命令中包含了一个不正确的文件名或参数。Go 编译器期望接收到
.go文件作为输入,但传递了一个非
.go文件名
tt`。
修改go build -mod=vendor -tags=production -o tt agent/main.go