我正在学习如何将项目包装在 docker 容器中。当我go build .在项目的根目录执行时(没有汇编),然后一切都被正常地汇编成二进制文件,当我在同一个地方执行它时,会docker build .弹出:
Step 6/13 : RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o app .
---> Running in af2d1c89685c
# github.com/gin-gonic/gin/binding
go/src/github.com/gin-gonic/gin/binding/json.go:50:10: decoder.DisallowUnknownFields undefined (type *"encoding/json".Decoder has no field or method DisallowUnknownFields)
The command '/bin/sh -c CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o app .' returned a non-zero code: 2
告诉我怎么回事。在培训项目中,有使用 MongoDB 的工作,并且序列化是不同的。
这种方法是在Go 1.10中引入的。因此,您的容器中有旧版本。您可以使用以下命令进行检查: