2017-09-01 3 views
7

Ce code compilé OK à l'aide version antérieure de golang (1.8.3) ne cependant compiler après la mise à niveau à la nouvelle golang (1,9)go build échoue: runtime/mstkbar.go: 151: 10: debug.gcstackbarrieroff non définie

~/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 

Des idées? En fait, cette erreur se produit pour toute mise à niveau de la version golang, pas seulement les versions que j'ai mentionnées ici.

PS obtenir également mêmes erreurs lors de l'émission: aller chercher -v -t/...

Répondre

21

SOLUTION:. Vous devez d'abord supprimer précédente golang installer avant d'installer une nouvelle version de go

type go # issue this to confirm where your go lives 

une sortie typique:

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

donc enlever juste

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

avant d'installer une nouvelle version

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 
1

J'utilise Windows 10. Je dois désinstaller go18 avec le panneau de configuration (ne faites pas confiance au programme d'installation 1.9 quand il demande de désinstaller la version précédente - faites-le à la main). Après cela, je supprime c: \ go - le goroot par défaut et seulement après cela - installer 1.9. Dans mon cas c'était 1.9.2 Et bien sûr vérifiez votre GOROOT & & GOPATH