Go版本升级后编译出错:Load redeclared in this block
生活随笔
收集整理的這篇文章主要介紹了
Go版本升级后编译出错:Load redeclared in this block
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
今天打算把Go由1.11.4升級到1.15.2,升級的方法就兩步,
先上Go官方下載頁面( https://golang.org/dl/ )下載windows對應的壓縮包
下載好后把壓縮包解壓到相應的目錄:
覆蓋安裝就可以了
因為是升級,不是初次安裝,之前已經把PATH設置好了,就不用管了。
之后執行以下命令,查看Go版本:
E:\GO2\src>go version go version go1.15.2 windows/amd64看到已經是1.15.2了,以為任務結束了。
但是用Go編譯自己的程序,輸出一大段如下錯誤:
# runtime/internal/atomic C:\Go\src\runtime\internal\atomic\atomic_amd64x.go:13:6: Load redeclared in this block C:\Go\src\runtime\internal\atomic\atomic_amd64x.go:19:6: Loadp redeclared in this blockprevious declaration at C:\Go\src\runtime\internal\atomic\atomic_amd64.go:22:32previous declaration at C:\Go\src\runtime\internal\atomic\atomic_amd64.go:28:26 C:\Go\src\runtime\internal\atomic\atomic_amd64x.go:30:6: Xadd redeclared in this blockprevious declaration at C:\Go\src\runtime\internal\atomic\atomic_amd64.go:39:37 C:\Go\src\runtime\internal\atomic\atomic_amd64x.go:33:6: Xadd64 redeclared in this block previous declaration at C:\Go\src\runtime\internal\atomic\atomic_amd64.go:42:39 C:\Go\src\runtime\internal\atomic\atomic_amd64x.go:36:6: Xadduintptr redeclared in this block previous declaration at C:\Go\src\runtime\internal\atomic\atomic_amd64.go:45:47previous declaration at C:\Go\src\runtime\internal\atomic\atomic_amd64.go:48:36 C:\Go\src\runtime\internal\atomic\atomic_amd64x.go:42:6: Xchg64 redeclared in this block C:\Go\src\runtime\internal\atomic\atomic_amd64x.go:45:6: Xchguintptr redeclared in this block previous declaration at C:\Go\src\runtime\internal\atomic\atomic_amd64.go:54:45 C:\Go\src\runtime\internal\atomic\atomic_amd64x.go:48:6: And8 redeclared in this blockprevious declaration at C:\Go\src\runtime\internal\atomic\atomic_amd64.go:63:27 C:\Go\src\runtime\internal\atomic\atomic_amd64x.go:48:6: too many errors錯誤提示中說,atomic中的很多內容都重定義了,打開目錄/go/src/runtime/internal/atomic下的atomic_amd64x.go和atomic_amd64.go,發現內容相近。
猜想可能新版本的源碼文件名變更了,由于我們的新版本是直接解壓過去的,導致老版本和新版本的源碼文件同時存在。
所以直接不覆蓋安裝了,把老文件夾里的東西都刪了,然后裝新的。
之后用Go編譯程序就沒有錯誤了。
總結一下,安裝Go時,如果選擇安裝在老版本目錄,最好先把老版本完整刪除掉。
總結
以上是生活随笔為你收集整理的Go版本升级后编译出错:Load redeclared in this block的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Leetcode 每日一题 40 组合2
- 下一篇: ftp服务器在线浏览,ftp服务器PDF