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 (标签-STM32|关键词-智能小车)
  • ¥20 关于#stm32#的问题,请各位专家解答!
  • ¥15 (标签-python)
  • ¥15 第一个已完成,求第二个做法
  • ¥20 搭建awx,试了很多版本都有错
  • ¥15 java corba的客户端该如何指定使用本地某个固定IP去连接服务端?
  • ¥15 activiti工作流问题,求解答
  • ¥15 有人写过RPA后台管理系统么?
  • ¥15 Bioage计算生物学年龄
  • ¥20 如何将FPGA Alveo U50恢复原来出厂设置哇?