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)
}
You don't have the correct version of Go installed. sync.Pool
was only added in Go 1.3. Try updating your local go package, verify you are running 1.3, and try again.
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.
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