英文:
go project build failed: lfstackPack redeclared in this block
问题
我是你的中文翻译助手,以下是翻译好的内容:
我刚开始学习Go语言,当我构建我的项目时,返回了以下错误:
/usr/local/go/bin/go run /home/qiuwei/GoWorkSpace/src/LearnGo/SoHi/Hello.go
# runtime
/usr/local/go/src/runtime/lfstack_amd64.go:16: 在此块中重新声明了lfstackPack
之前的声明在/usr/local/go/src/runtime/lfstack_64bit.go:37
/usr/local/go/src/runtime/lfstack_amd64.go:20: 在此块中重新声明了lfstackUnpack
之前的声明在/usr/local/go/src/runtime/lfstack_64bit.go:41
/usr/local/go/src/runtime/os_linux_generic.go:13: 在此块中重新声明了_SS_DISABLE
之前的声明在/usr/local/go/src/runtime/os2_linux_generic.go:12
/usr/local/go/src/runtime/os_linux_generic.go:14: 在此块中重新声明了_NSIG
之前的声明在/usr/local/go/src/runtime/os2_linux_generic.go:13
/usr/local/go/src/runtime/os_linux_generic.go:15: 在此块中重新声明了_SI_USER
之前的声明在/usr/local/go/src/runtime/os2_linux_generic.go:14
/usr/local/go/src/runtime/os_linux_generic.go:16: 在此块中重新声明了_SIG_BLOCK
之前的声明在/usr/local/go/src/runtime/os2_linux_generic.go:15
/usr/local/go/src/runtime/os_linux_generic.go:17: 在此块中重新声明了_SIG_UNBLOCK
之前的声明在/usr/local/go/src/runtime/os2_linux_generic.go:16
/usr/local/go/src/runtime/os_linux_generic.go:18: 在此块中重新声明了_SIG_SETMASK
之前的声明在/usr/local/go/src/runtime/os2_linux_generic.go:17
/usr/local/go/src/runtime/os_linux_generic.go:19: 在此块中重新声明了_RLIMIT_AS
之前的声明在/usr/local/go/src/runtime/os2_linux_generic.go:18
/usr/local/go/src/runtime/os_linux_generic.go:25: 在此块中重新声明了sigset
之前的声明在/usr/local/go/src/runtime/os2_linux_generic.go:24
/usr/local/go/src/runtime/os_linux_generic.go:25: 错误太多
显示我的go env:
export PATH=$PATH:/usr/local/go/bin
export GOPATH=$HOME/GoWorkSpace
Go版本:go1.6.3
。操作系统:Ubuntu 14.04
如何修复这个问题?
英文:
I am new to Go, when I built my project, it returned the following the error:
/usr/local/go/bin/go run /home/qiuwei/GoWorkSpace/src/LearnGo/SoHi/Hello.go
# runtime
/usr/local/go/src/runtime/lfstack_amd64.go:16: lfstackPack redeclared in this block
previous declaration at /usr/local/go/src/runtime/lfstack_64bit.go:37
/usr/local/go/src/runtime/lfstack_amd64.go:20: lfstackUnpack redeclared in this block
previous declaration at /usr/local/go/src/runtime/lfstack_64bit.go:41
/usr/local/go/src/runtime/os_linux_generic.go:13: _SS_DISABLE redeclared in this block
previous declaration at /usr/local/go/src/runtime/os2_linux_generic.go:12
/usr/local/go/src/runtime/os_linux_generic.go:14: _NSIG redeclared in this block
previous declaration at /usr/local/go/src/runtime/os2_linux_generic.go:13
/usr/local/go/src/runtime/os_linux_generic.go:15: _SI_USER redeclared in this block
previous declaration at /usr/local/go/src/runtime/os2_linux_generic.go:14
/usr/local/go/src/runtime/os_linux_generic.go:16: _SIG_BLOCK redeclared in this block
previous declaration at /usr/local/go/src/runtime/os2_linux_generic.go:15
/usr/local/go/src/runtime/os_linux_generic.go:17: _SIG_UNBLOCK redeclared in this block
previous declaration at /usr/local/go/src/runtime/os2_linux_generic.go:16
/usr/local/go/src/runtime/os_linux_generic.go:18: _SIG_SETMASK redeclared in this block
previous declaration at /usr/local/go/src/runtime/os2_linux_generic.go:17
/usr/local/go/src/runtime/os_linux_generic.go:19: _RLIMIT_AS redeclared in this block
previous declaration at /usr/local/go/src/runtime/os2_linux_generic.go:18
/usr/local/go/src/runtime/os_linux_generic.go:25: sigset redeclared in this block
previous declaration at /usr/local/go/src/runtime/os2_linux_generic.go:24
/usr/local/go/src/runtime/os_linux_generic.go:25: too many errors
Show my go env:
export PATH=$PATH:/usr/local/go/bin
export GOPATH=$HOME/GoWorkSpace
Go version: go1.6.3
. OS: Ubuntu 14.04
How to fix it?
答案1
得分: 39
删除所有提取的文件,并重新提取1.6版本的tar文件。如果仍然遇到问题,您可以尝试重新启动终端。
sudo rm -rf /usr/local/go
tar -C /usr/local -xzf go$VERSION.$OS-$ARCH.tar.gz
更多详细信息,请参阅此链接。
英文:
Remove all the extracted files and extract the 1.6 tar again. If you are still seeing the issue, you may try restarting your Terminal as well.
sudo rm -rf /usr/local/go
tar -C /usr/local -xzf go$VERSION.$OS-$ARCH.tar.gz
For more detail, see this
答案2
得分: 1
你在使用Go 1.18时也会遇到这个错误,就像这个reddit帖子所示。
> 我通过删除现有的1.17安装来解决了我的问题;尝试清除/usr/local/go文件夹,然后再次解压1.18的tar包。
>
> 我猜测一些源文件的名称已更改(或类似的情况),这意味着在原地解压1.18会导致这些重声明错误。
这在问题47773中有所说明。
这就是为什么Windows安装程序在安装之前会先卸载Go 1.17,然后再安装1.18。
英文:
You will see this error also when using Go 1.18, as illustrated by this reddit thread.
> I resolved my issue by removing the pre-existing 1.17 installation; try purging the /usr/local/go folder and then untar the 1.18 tarball again.
>
> My guess is that some source files had their names changed (or something along those lines), which means untaring 1.18 in-place causes these redeclaration errors.
This is illustrated by issue 47773.
That is why the Windows installer, for install, starts by uninstalling Go 1.17, before installing 1.18.
答案3
得分: -1
请执行以下操作:
- 运行命令 "go mod tidy"
- 运行命令 "go mod vendor"
英文:
do the following:
- go mod tody
- go mod vendor
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论