【问题标题】:go build fails : runtime/mstkbar.go:151:10: debug.gcstackbarrieroff undefinedgo build 失败:runtime/mstkbar.go:151:10: debug.gcstackbarrieroff undefined
【发布时间】:2017-09-01 23:57:46
【问题描述】:

此代码使用先前版本的 golang (1.8.3) 编译正常,但升级到新的 golang (1.9) 后编译失败

~/src/gopath/src/github.com/scottstensland/infosynth $ go build infosynth.go
# runtime
/usr/local/go/src/runtime/mstkbar.go:151:10: debug.gcstackbarrieroff undefined (type struct { allocfreetrace int32; cgocheck int32; efence int32; gccheckmark int32; gcpacertrace int32; gcshrinkstackoff int32; gcrescanstacks int32; gcstoptheworld int32; gctrace int32; invalidptr int32; sbrk int32; scavenge int32; scheddetail int32; schedtrace int32 } has no field or method gcstackbarrieroff)
/usr/local/go/src/runtime/mstkbar.go:162:24: division by zero
/usr/local/go/src/runtime/mstkbar.go:162:43: invalid expression unsafe.Sizeof(composite literal)
/usr/local/go/src/runtime/mstkbar.go:162:44: undefined: stkbar
/usr/local/go/src/runtime/mstkbar.go:212:4: gp.stkbar undefined (type *g has no field or method stkbar)
/usr/local/go/src/runtime/mstkbar.go:213:15: gp.stkbar undefined (type *g has no field or method stkbar)
/usr/local/go/src/runtime/mstkbar.go:216:23: undefined: stackBarrierPC
/usr/local/go/src/runtime/mstkbar.go:226:28: gp.stkbarPos undefined (type *g has no field or method stkbarPos)
/usr/local/go/src/runtime/mstkbar.go:227:19: gp.stkbarPos undefined (type *g has no field or method stkbarPos)
/usr/local/go/src/runtime/mstkbar.go:248:41: undefined: stkbar
/usr/local/go/src/runtime/mstkbar.go:227:19: too many errors

有什么想法吗?实际上,任何 golang 版本升级都会发生此错误,而不仅仅是我在这里提到的版本。

PS 发出时也会出现同样的错误:go get -v -t ./...

【问题讨论】:

    标签: go installation


    【解决方案1】:

    解决方案:在安装新的 go 版本之前,您必须先删除以前的 golang 安装

    type go    # issue this to confirm where your go lives
    

    一个典型的输出:

    go is /usr/local/go/bin/go  # delete /usr/local/go not just /usr/local/go/bin/go
    

    所以删除它

    sudo rm -rf /usr/local/go  #  OP's missing step else above errors
    

    安装新版本之前

    export golang_ver=$(curl https://golang.org/VERSION?m=text 2> /dev/null)
    wget https://storage.googleapis.com/golang/${golang_ver}.linux-amd64.tar.gz
    sudo tar -C /usr/local -xzf ${golang_ver}.linux-amd64.tar.gz
    

    【讨论】:

      【解决方案2】:

      我使用的是 Windows10。我必须使用控制面板卸载 go18(当他要求卸载以前的版本时不要相信 1.9 安装程序 - 手动执行)。之后我删除 c:\go - 默认的 goroot 并且仅在此之后 - 安装 1.9。就我而言,它是 1.9.2 当然还要检查你的 GOROOT && GOPATH

      【讨论】:

        猜你喜欢
        • 2014-02-13
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2015-10-13
        • 2020-09-14
        • 2016-10-24
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多