4

When trying to run go build in my src directory, I get this error:

imports runtime: C source files not allowed when not using cgo: atomic_amd64x.c defs.c float.c heapdump.c lfstack.c malloc.c mcache.c mcentral.c mem_linux.c mfixalloc.c mgc0.c mheap.c msize.c os_linux.c panic.c parfor.c proc.c runtime.c signal.c signal_amd64x.c signal_unix.c stack.c string.c sys_x86.c vdso_linux_amd64.c

When I first started learning Go I ran sudo apt-get install golang on my Ubuntu laptop (14.04 LTS, 64bit) which installed version 1.2. That ran fine and I was able to build, install and run apps. I then ran autoremove to get rid of it, then installed 1,4 from the golang website.

What's going on here, and how can I fix it? Googling the error shows that it has something to do with a previously installed version of go, but I thought autoremove would clean it and any dependencies up (which it seemed to, as I made sure I couldn't find golang anywhere, before installing from source.

Any clues?

2
  • 1
    It might be a silly question, but is the C compiler still installed? Commented Jan 5, 2015 at 3:03
  • @JamesHenstridge I think you might be on to something here. The 64 bit version was installed, but I may have needed the 32 bit, even though I'm not building 32 bit binaries. Installing the 32 bit C compiler using instructions from github.com/golang/go/wiki/InstallFromSource#Install_C_tools seems to have fixed it. Will answer after getting a sample app to build Commented Jan 5, 2015 at 3:26

4 Answers 4

4

I fixed this by unsetting GOROOT in the environment. It was pointing to another Go installation.

Sign up to request clarification or add additional context in comments.

Comments

2

So James was on the right track. I had gcc installed, but not the 32 bit version. Following advice from https://github.com/golang/go/wiki/InstallFromSource#Install_C_tools on how to install the 32 bit version fixed the issue.

Comments

1

I had a similar problem after upgrading to go 1.5. Removing the /usr/local/go directory and reinstalling from the tarball fixed the problem.

Comments

0

if you install Go 1.4 and then install Go 1.5. But don't change GOROOT environment variables. Change GOROOT point to GO 1.5 path.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.