内容简介:今天打算把Go升级到先上Go官方下载页面(下载好后把压缩包解压到相应的目录:
今天打算把 Go 升级到 1.14.2
,升级的方法就两步,
先上Go官方下载页面( https://golang.org/dl/
)下载macos对应的二进制包( 1.14.2
地址 https://dl.google.com/go/go1.14.2.darwin-amd64.tar.gz
)
下载好后把压缩包解压到相应的目录:
$sudo tar -C /usr/local -xzf go1.14.2.darwin-amd64.tar.gz
因为是升级,不是初次安装,之前已经把PATH设置好了,就不用管了。
之后执行以下命令,查看Go版本:
$go version go version go1.14.2 darwin/amd64
看到已经是 1.14.2
了,美滋滋。
但是用Go编译自己的程序,输出一大段如下错误:
# runtime/internal/atomic /usr/local/go/src/runtime/internal/atomic/atomic_amd64x.go:18:6: Load redeclared in this block previous declaration at /usr/local/go/src/runtime/internal/atomic/atomic_amd64.go:16:24 /usr/local/go/src/runtime/internal/atomic/atomic_amd64x.go:24:6: Loadp redeclared in this block previous declaration at /usr/local/go/src/runtime/internal/atomic/atomic_amd64.go:22:32 /usr/local/go/src/runtime/internal/atomic/atomic_amd64x.go:30:6: Load64 redeclared in this block previous declaration at /usr/local/go/src/runtime/internal/atomic/atomic_amd64.go:28:26 /usr/local/go/src/runtime/internal/atomic/atomic_amd64x.go:36:6: LoadAcq redeclared in this block previous declaration at /usr/local/go/src/runtime/internal/atomic/atomic_amd64.go:34:27 /usr/local/go/src/runtime/internal/atomic/atomic_amd64x.go:41:6: Xadd redeclared in this block previous declaration at /usr/local/go/src/runtime/internal/atomic/atomic_amd64.go:39:37 /usr/local/go/src/runtime/internal/atomic/atomic_amd64x.go:44:6: Xadd64 redeclared in this block previous declaration at /usr/local/go/src/runtime/internal/atomic/atomic_amd64.go:42:39 /usr/local/go/src/runtime/internal/atomic/atomic_amd64x.go:47:6: Xadduintptr redeclared in this block previous declaration at /usr/local/go/src/runtime/internal/atomic/atomic_amd64.go:45:47 /usr/local/go/src/runtime/internal/atomic/atomic_amd64x.go:50:6: Xchg redeclared in this block previous declaration at /usr/local/go/src/runtime/internal/atomic/atomic_amd64.go:48:36 /usr/local/go/src/runtime/internal/atomic/atomic_amd64x.go:53:6: Xchg64 redeclared in this block previous declaration at /usr/local/go/src/runtime/internal/atomic/atomic_amd64.go:51:38 /usr/local/go/src/runtime/internal/atomic/atomic_amd64x.go:56:6: Xchguintptr redeclared in this block previous declaration at /usr/local/go/src/runtime/internal/atomic/atomic_amd64.go:54:45 /usr/local/go/src/runtime/internal/atomic/atomic_amd64x.go:56:6: too many errors
错误提示中说,atomic中的很多内容都重定义了,打开目录 /usr/local/go/src/runtime/internal/atomic
下的 atomic_amd64x.go
和 atomic_amd64.go
,发现内容都差不多。
猜想可能新版本的源码文件名变更了,由于我们的新版本是直接解压过去的,导致老版本和新版本的源码文件同时存在。
尝试将 /usr/local/go
整个删除,再次 sudo tar -C /usr/local -xzf go1.14.2.darwin-amd64.tar.gz
安装新版本。
之后用Go编译程序就没有错误了。
上 /usr/local/go/src/runtime/internal/atomic
目录看,只有 atomic_amd64.go
文件了,说明猜想正确。问题解决。
总结一下,安装Go时,如果选择安装在老版本目录,最好先把老版本完整删除掉。
本文完,作者 yoko ,尊重劳动人民成果,转载请注明原文出处: https://pengrl.com/p/20052/
以上所述就是小编给大家介绍的《升级Go版本后编译出错:Load redeclared in this block》,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对 码农网 的支持!
猜你喜欢:- [译] 如何验证代码是否被编译器优化后出错?
- 如何避免空指针出错?
- 如何避免特效渲染出错?
- OmniROM:“Flex checkpolicy”出错
- Python安装软件包出错
- 让gulp watch出错时不退出
本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们。
PHP and MySQL Web Development
Luke Welling、Laura Thomson / Sams / July 25, 2007 / $49.99
Book Description PHP and MySQL Web Development teaches you to develop dynamic, secure, commerical Web sites. Using the same accessible, popular teaching style of the three previous editions, this b......一起来看看 《PHP and MySQL Web Development》 这本书的介绍吧!