出错记录笔记

记录报错

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

  • 10
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值