如何在安装使用docker的应用程序时解决"undefined:math.Round"的问题

mis*_*sha 0 go docker

我制作golang api的代码,我已经在其中导入了一些包math.但是在通过sudo docker build -t users/micro .一步运行Then来构建图像时,它会给我错误.

错误

 Step 6/8 : RUN go install
 ---> Running in 454784b3ceef
 # bkapiv/users/utils
 utils/CommonFunctions.go:189:9: undefined: math.Round
Run Code Online (Sandbox Code Playgroud)

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
Run Code Online (Sandbox Code Playgroud)

导入的包是

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 }
Run Code Online (Sandbox Code Playgroud)

我将如何解决我的错误

jus*_*nas 8

该功能Round()math包围棋1.10只介绍(请参见发行说明).您的Dockerfile使用较旧的1.9.6版本,因此您必须升级.