After upgrading my go
installation folder to Go 1.14
sudo tar -C /usr/local -xzf go1.14.linux-amd64.tar.gz
I am receiving a runtime error every time I try to build a program:
~/playground/go/src/hello go build hello
# 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
I tried to downgrade to version 1.13.8
and build
and run
go fine.
sudo rm -rf /usr/local/go && sudo tar -C /usr/local -xzf go1.13.8.linux-amd64.tar.gz
~ go version
go version go1.13.8 linux/amd64
~/go go build hello && go run hello
hello, world
My OS is Linux Mint 19.2.
The runtime error might be caused by a bug that hasn't yet been patched in the release that you're using. For example, some users report a runtime error when they use NVIDIA GeForce Experience to check for graphics card updates. In this scenario, you'd update the NVIDIA program.
Here, variable N is assigned a garbage value resulting in a runtime error. Sometimes, since it depends on the compiler how it assigned the garbage value. This can be resolved by declaring arr [N] after scanning the value for variable n and checking if it is the upper or lower limit of the array / vector index.
Reasons for the runtime error vary on different applications. If you are not sure what causes the error actually, pay attention to the content below. Runtime error is associated with hardware or software that stops applications and programs to run properly. Programming glitches are not rectified in the process of application development.
So, how do you fix an internal error? You can't. The error is not in your code. Only the developer of the programming tool can fix it. But that does not mean there is nothing you can do.
This error is reproducible and occurs when the target directory has been already used for older Go installations and some files have been renamed (compared to previous version).
For instance:
in Go 1.13.8 file go/src/runtime/internal/atomic/atomic_amd64x.go
has been moved to go/src/runtime/internal/atomic/atomic_amd64.go
in Go 1.14.
Extracting without cleaning target directory triggers "previous declaration" error because func Xchguintptr
is declared both in go/src/runtime/internal/atomic/atomic_amd64x.go
and go/src/runtime/internal/atomic/atomic_amd64.go
To avoid this type of error remove the installation folder (/usr/local/go) and reinstall Go 1.14.
sudo rm -rf /usr/local/go && sudo tar -C /usr/local -xzf go1.14.linux-amd64.tar.gz
Test again:
~/go/src/hello go version
go version go1.14 linux/amd64
~/go/src/hello go build hello && go run hello
hello, world
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With