douxing1969 2018-04-06 18:34
浏览 229
已采纳

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
  • 写回答

1条回答 默认 最新

  • duanmie9682 2018-04-09 19:21
    关注

    It got resolved after I reset docker to factory defaults.

    Reset Docker

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 求差集那个函数有问题,有无佬可以解决
  • ¥15 【提问】基于Invest的水源涵养
  • ¥20 微信网友居然可以通过vx号找到我绑的手机号
  • ¥15 寻一个支付宝扫码远程授权登录的软件助手app
  • ¥15 解riccati方程组
  • ¥15 display:none;样式在嵌套结构中的已设置了display样式的元素上不起作用?
  • ¥15 使用rabbitMQ 消息队列作为url源进行多线程爬取时,总有几个url没有处理的问题。
  • ¥15 Ubuntu在安装序列比对软件STAR时出现报错如何解决
  • ¥50 树莓派安卓APK系统签名
  • ¥65 汇编语言除法溢出问题