go程序编译出现的错误总结(陆续更新)

本文详细解析了在Go语言编程中遇到的重复声明错误,通常发生在同一作用域内的变量或函数被多次定义。文章提供了具体的错误示例,如在/usr/local/go/src/runtime/map.go文件中发现的bucketCntBits等变量的重复声明问题。分析指出,此类错误可能由环境配置冲突引起,例如在不同路径下安装了多个Go版本。解决方案包括彻底清除旧的Go安装,然后重新安装,确保环境中只有一个Go版本被正确引用。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

错误一:
/usr/local/go/src/runtime/map.go:64:2: bucketCntBits redeclared in this block
previous declaration at /usr/local/go/src/runtime/hashmap.go:64:18
/usr/local/go/src/runtime/map.go:65:2: bucketCnt redeclared in this block
previous declaration at /usr/local/go/src/runtime/hashmap.go:65:23
/usr/local/go/src/runtime/map.go:69:2: loadFactorNum redeclared in this block
previous declaration at /usr/local/go/src/runtime/hashmap.go:69:18
/usr/local/go/src/runtime/map.go:70:2: loadFactorDen redeclared in this block
previous declaration at /usr/local/go/src/runtime/hashmap.go:70:18
/usr/local/go/src/runtime/map.go:76:2: maxKeySize redeclared in this block
previous declaration at /usr/local/go/src/runtime/hashmap.go:76:17
/usr/local/go/src/runtime/map.go:77:2: maxValueSize redeclared in this block
previous declaration at /usr/local/go/src/runtime/hashmap.go:77:17
/usr/local/go/src/runtime/map.go:82:2: dataOffset redeclared in this block
previous declaration at /usr/local/go/src/runtime/hashmap.go:85:4
/usr/local/go/src/runtime/map.go:91:2: empty redeclared in this block
previous declaration at /usr/local/go/src/runtime/hashmap.go:91:19
/usr/local/go/src/runtime/map.go:92:2: evacuatedEmpty redeclared in this block
previous declaration at /usr/local/go/src/runtime/hashmap.go:92:19
/usr/local/go/src/runtime/map.go:93:2: evacuatedX redeclared in this block
previous declaration at /usr/local/go/src/runtime/hashmap.go:93:19
/usr/local/go/src/runtime/map.go:93:2: too many errors
 
分析:
此问题可能是由于go的按照包被破坏导致,我出现这个错误是由于在usr/bin目录下安装了一份,后来又在/usr/local下面又按照了一份,由于/usr/local下面的总是不生效所以使用yum remove go将/usr/bin下面的删除,删除完成之后就导致了这个错误
 
解决方案:先手动删除之前安装的包,再重新按照
rm -rf /usr/local/go
sudo tar -C /usr/local -xzf go1.11.linux-amd64.tar.gz

转载于:https://my.oschina.net/u/1013544/blog/3004054

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值