logo

Golang - Troubleshooting

use of untyped nil in assignment

Symptom

If you are trying to create a nil pointer like this:

foo := nil

The compiler would complain about UntypedNilUse:

use of untyped nil in assignment

Solution

Use var foo *Foo instead.

"undefined: atomic.Pointer"

Reason: wrong go version.

Fix: Download the right version, e.g.

go install golang.org/dl/go1.20.4@latest
~/go/bin/go1.20.4 download
~/go/bin/go1.20.4 env GOROOT