本文是基于mac,安裝go1.14版本之后,執(zhí)行一個基本的go文件報錯了。
創(chuàng)新互聯(lián)專注于臺州網(wǎng)站建設(shè)服務(wù)及定制,我們擁有豐富的企業(yè)做網(wǎng)站經(jīng)驗。 熱誠為您提供臺州營銷型網(wǎng)站建設(shè),臺州網(wǎng)站制作、臺州網(wǎng)頁設(shè)計、臺州網(wǎng)站官網(wǎng)定制、小程序開發(fā)服務(wù),打造臺州網(wǎng)絡(luò)公司原創(chuàng)品牌,更為您提供臺州網(wǎng)站排名全網(wǎng)營銷落地服務(wù)。
錯誤現(xiàn)象:
執(zhí)行下面的go的文件報下面的錯誤了
# hello.go package main import "fmt" func main(){ fmt.Println("hello world") }
運(yùn)行效果如下:
? test go run hello.go # runtime/internal/atomic /usr/local/go/src/runtime/internal/atomic/atomic_amd64x.go:13: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:19: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:25: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:31: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:36: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:39: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:42: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:45: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:48: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:51: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:51:6: too many errors
原因:
由于安裝新版本的時候,沒有刪除舊版本,導(dǎo)致安裝包的有些關(guān)聯(lián)發(fā)生錯誤
解決方案:
先手動刪除之前安裝的包,再重新按照
rm -rf /usr/local/go sudo tar -C /usr/local -xzf go1.14.1.darwin-amd64.tar.gz
以上就是go語言中一種常見的錯誤的詳細(xì)內(nèi)容,更多請關(guān)注創(chuàng)新互聯(lián)其它相關(guān)文章!