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 操作系统相关算法中while();的含义
  • ¥15 CNVcaller安装后无法找到文件
  • ¥15 visual studio2022中文乱码无法解决
  • ¥15 关于华为5g模块mh5000-31接线问题
  • ¥15 keil L6007U报错
  • ¥15 webapi 发布到iis后无法访问
  • ¥15 初学者如何快速上手学习stm32?
  • ¥15 如何自动更换布娃娃图片上的衣服
  • ¥15 心理学eprime编程
  • ¥15 arduino esp8266开发