c - 去 1.5+ : Error - imports runtime: C source fil

我的程序与 go 1.4.2 完美构建。安装 go 1.5 后,出现以下错误。

imports runtime: C source files not allowed when not using cgo or SWIG: 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

错误与程序无关。即使是“Hello world”程序也会抛出同样的错误。

最佳答案

Remove Old 1.4.x go installation and then install go 1.5.

安装 go 1.5 后我遇到了同样的问题。问题是我在 1.4.2 的同一个地方安装了 go 1.5。 Go 1.5 不再使用 C,如果存在旧的 C 安装文件,它会抛出错误,如图所示。

如果您希望旧安装也存在,则将 1.5 安装到其他位置并将 GOROOT 设置为该位置。

希望对你有帮助。

编辑 1:对于 Linux 用户:

如果你下载了 go1.5*.tar.gz 那么你是这样做的:

tar -C /usr/local/ -xvf go1.5.linux-amd64.tar.gz

你的旧文件夹C文件没有被删除,所以正确的过程是:

首先:您应该删除旧的 go 文件夹。

sudo rm -rf /usr/local/go/

第二:然后运行

tar -C /usr/local/ -xvf go1.5.x.linux-amd64.tar.gz

关于c - 去 1.5+ : Error - imports runtime: C source files not allowed when not using cgo or SWIG,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32115229/

相关文章:

build - Unix : fast 'remove directory' for cleanin

build - 找不到工件的不可解析父 POM 和 'parent.relativePath' 点在

ios - 从 xcode 命令行生成 ipa

python - 将 build_ext 选项传递给 pip install

java - 无法找到 tools.jar。预计在 C :\Program Files\Java\j

ios - 防止 Xcode 每次都构建子项目

build - 更改 CMake 文件标准位置

haskell - 平行 cabal

java - 如何解决模块 X 的多个工件被检索到 Apache Ivy 中的同一个文件?

visual-studio - Visual Studio 可以在构建日志中添加时间戳吗?