I get error: reference to undefined identifier ‘sync.Pool’
message and this is working in Playground. What should I do?
package main
import (
"fmt"
"sync"
)
func main() {
var wg sync.Pool
fmt.Println(wg)
}
I get error: reference to undefined identifier ‘sync.Pool’
message and this is working in Playground. What should I do?
package main
import (
"fmt"
"sync"
)
func main() {
var wg sync.Pool
fmt.Println(wg)
}
If you installed go from source, check what $GOROOT
et ^$GOROOT_FINAL
refer to: if they differ, you need to reset your GOROOT
to GOROOT_FINAL
.
The value assumed by installed binaries and scripts when
$GOROOT
is not set explicitly.
It defaults to the value of$GOROOT
.If you want to build the Go tree in one location but move it elsewhere after the build, set
$GOROOT_FINAL
to the eventual location.
From the comments, the OP mentions:
go version
prints out
go version xgcc (Ubuntu 4.9.1-0ubuntu1) 4.9.1 linux/amd64
And $GOROOT/pkg/linux_amd64/sync.a
does exist.
I recommended to make sure $PATH
includes $GOROOT/bin
JimB added:
to be more specific, make sure your
$PATH
contains$GOROOT/bin
for the correctGOROOT
. I think you have two installations making this more confusing.