Build project failure

go

#1

Hi All!

I’m trying to build project of our company on my laptop.

cd project_dir
go build

then i get this error:

# github.com/aerospike/aerospike-client-go/types/atomic
/home/sugar/go/src/github.com/aerospike/aerospike-client-go/types/atomic/int.go:72: undefined: atomic.SwapInt64

This the piece of code from /aerospike-client-go/types/atomic/int.go:

70 // GetAndSet atomically sets current value to the given value and returns the old value.
 71 func (ai *AtomicInt) GetAndSet(newValue int) int {
 72     return int(atomic.SwapInt64(&ai.val, int64(newValue)))
 73 }

go env
GOARCH="386"
GOBIN="/home/sugar/go/bin"
GOCHAR="8"
GOEXE=""
GOHOSTARCH="386"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/sugar/go:/usr/lib/go/contrib"
GORACE=""
GOROOT="/usr/lib/go"
GOTOOLDIR="/usr/lib/go/pkg/tool/linux_386"
CC="gcc"
GOGCCFLAGS="-g -O2 -fPIC -m32 -pthread"
CGO_ENABLED="1"

Any suggestions? I also tried to reinstall sync/atomic with command

go get -u sync/atomic

#2

Looks like you are trying to compile the Go client on a 32bit OS. Unfortunately, only 64bit machines are supported at the moment.


#3

Khosrow Afroozeh, thank you for reply!

I tried it also at my dev-server, virtual machine:

sugar@backend01:~$ go env
GOROOT="/usr/lib/go"
GOBIN=""
GOARCH="amd64"
GOCHAR="6"
GOOS="linux"
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOTOOLDIR="/usr/lib/go/pkg/tool/linux_amd64"
GOGCCFLAGS="-g -O2 -fPIC -m64 -pthread"
CGO_ENABLED="1"

And i got exactly same result/


#4

Anton,

The atomic package is a part of Go std library. https://golang.org/pkg/sync/atomic/#SwapInt64

What is the go version you are using? Which linux distrib? How did you install Go? You may have an issue with your Go installation.

It is also always a good idea to do a $ go get -u for the client to make sure you are using the latest version.


#5

Khosrow_Afroozeh,

`sugar@backend01:~$ go version

go version go1`

`sugar@backend01:~$ uname -a

Linux backend01.setup-team.net 3.2.0-37-virtual #58-Ubuntu SMP Thu Jan 24 15:48:03 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux`

apt-get install golang

Yep, i think the same, some problems with my installation. Or bad proccessor emulation. But i have no time to expore, i got physical server with 64bit processor for my purposes, and there are all builds fine. I tried first “go get -u sync/atomic” and “go get -u all” before start this thread.

But anyway, Khosrow Afroozeh thank you very much for your help!


#6

You have installed a very old version of Go (version 1), which doesn’t have the atomic package.

Distributions are usually behind the curve when it comes to language versions, so if you want to install Go, it is better to install it via the instruction in their website: https://golang.org/doc/install

Don’t hesitate to reach out in case you encounter other issues.

Best, K.


#7

Khosrow_Afroozeh,

I have installed latest Go on that VM, and now project builds fine.

Thank you for help!