如何解决"一国两制"问题,;未定义:math.Round“;使用docker安装go应用程序时

如何解决"一国两制"问题,;未定义:math.Round“;使用docker安装go应用程序时,docker,go,Docker,Go,我制作了golang api的代码,并在其中导入了一些包,如math。但是,当运行sudocker build-t users/micro.构建映像时,一步就会出现错误 错误 Dockerfile # Start from a Debian image with the latest version of Go installed # and a workspace (GOPATH) configured at /go. FROM golang:1.9.6 WORKDIR /go/src/b

我制作了golang api的代码,并在其中导入了一些包,如
math
。但是,当运行sudocker build-t users/micro.构建映像时,一步就会出现错误

错误

Dockerfile

# Start from a Debian image with the latest version of Go installed
# and a workspace (GOPATH) configured at /go.
FROM golang:1.9.6


WORKDIR /go/src/bkapiv/users

# Copy the local package files to the container's workspace.
ADD . /go/src/bkapiv/users

# Build the outyet command inside the container.
# (You may fetch or manage dependencies here,
# either manually or with a tool like "godep".)
RUN cd /go/src
RUN go-wrapper download   # "go get -d -v ./..."
RUN go install

# Run the outyet command by default when the container starts.
ENTRYPOINT /go/bin/users

# Document that the service listens on port 8080.
EXPOSE 8080
进口包装是

package utils

import (
 "bytes"
 "fmt"
 "math"
 "math/rand"
 "os/exec"
 "reflect"
 "sort"
 "strconv"
 "time"
)

 187 func Round(x, unit float64) float64 {
 188        // for this line it will giving me the error 
 189    return math.Round(x/unit) * unit
 190 }
如何解决我的错误

来自
math
软件包的函数
Round()
仅在Go 1.10()中引入。您的Dockerfile使用较旧的1.9.6版本,因此您必须升级

package utils

import (
 "bytes"
 "fmt"
 "math"
 "math/rand"
 "os/exec"
 "reflect"
 "sort"
 "strconv"
 "time"
)

 187 func Round(x, unit float64) float64 {
 188        // for this line it will giving me the error 
 189    return math.Round(x/unit) * unit
 190 }