golang:导入gin-gonic / gin时,macOS上的alpine docker容器抛出“ go.string的无效符号版本”

I am trying to run a very simple go/gin program on golang:alpine docker image. This fails to run/build.

Run container:

docker run -it --rm golang:1.10.1-alpine sh

In the container paste:

apk update && apk add git gcc musl-dev

go get github.com/gin-gonic/gin

cat <<EOT > src/main.go
package main
import _ "github.com/gin-gonic/gin"
func main() {
}
EOT

go run src/main.go

The error:

# command-line-arguments
2018/04/06 18:07:33 invalid symbol version for "go.string.\"aa87ca22be8b05378eb1c71ef320ad746e1d3b628ba79b9859f741e082542a3855\xdb\x0f\x849\x0e\x00\x00H\x8b[\bH\x83\xfb\x01\x0f\x8f\x17\x00\x00H\x8bH H\x85\xc9\x0f\x84\x01": -7

Host Machine: macOS High Sierra 10.13.3, MacBook Pro Mid 2014, Intel i5

Docker version:

Client:
 Version:   18.03.0-ce
 API version:   1.37
 Go version:    go1.9.4
 Git commit:    0520e24
 Built: Wed Mar 21 23:06:22 2018
 OS/Arch:   darwin/amd64
 Experimental:  false
 Orchestrator:  swarm

Server:
 Engine:
  Version:  18.03.0-ce
  API version:  1.37 (minimum version 1.12)
  Go version:   go1.9.4
  Git commit:   0520e24
  Built:    Wed Mar 21 23:14:32 2018
  OS/Arch:  linux/amd64
  Experimental: false

This works without error on golang/stretch image, though:

✗ dk run -it --rm golang:1.10.1-stretch bash                                        11:24AM
root@5d98f42504c2:/go# go get github.com/gin-gonic/gin
root@5d98f42504c2:/go#
root@5d98f42504c2:/go# cat <<EOT > src/main.go
> package main
> import _ "github.com/gin-gonic/gin"
> func main() {
> }
> EOT
root@5d98f42504c2:/go#
root@5d98f42504c2:/go# go run src/main.go
root@5d98f42504c2:/go#

What could be going wrong with alpine? Any suggestion is appreciated.


More Information

Same error with CGO disabled.

This is a build time failure and with -x option fails at:

EOF
mkdir -p $WORK/b001/exe/
cd .
/usr/local/go/pkg/tool/linux_amd64/link 
-o $WORK/b001/exe/a.out 
-importcfg $WORK/b001/importcfg.link 
-buildmode=exe 
-buildid=UZcMyOX9lILP9hahS-FF/kCN0nlKO7qaS5D1mwkHf/i8lsdHfkhJNsud-tI68Q/UZcMyOX9lILP9hahS-FF 
-extld=gcc /root/.cache/go-build/55/55d1e3d2979a75ff5a13bc75c855482f90c32615d3b9e9d42ed096051efec200-d
# command-line-arguments
2018/04/06 21:28:17 invalid symbol version for "go.string.\"aa87ca22be8b05378eb1c71ef320ad746e1d3b628ba79b9859f741e0
82542a3855\xdb\x0f\x849\x0e\x00\x00H\x8b[\bH\x83\xfb\x01\x0f
\x8f\x17\x00\x00H\x8bH H\x85\xc9\x0f\x84\x01": -7
doujiku1028
doujiku1028 没有CGO会失败,并出现相同的错误。这是构建时间失败。将输出添加到描述中。谢谢。
2 年多之前 回复
duanjing2013
duanjing2013 我无法复制该问题。您是否尝试过在没有CGO的情况下进行建设?您是否尝试过使用-x进行构建以查看其是否在构建时失败,并且哪个命令可能失败了?您确定您拥有最新的高山图片吗?
2 年多之前 回复

1个回答



在我将docker重置为出厂默认设置后,此问题得到解决。</ p>

”重置Docker“ </ p>
</ div>

展开原文

原文

It got resolved after I reset docker to factory defaults.

Reset Docker

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问
相关内容推荐