我正在尝试使用docker在golang中部署一个应用程序。
我先试过docker build -t go-k8s .,再试过docker run -it {{image-id}}
# build stage
FROM golang:latest AS builder
RUN mkdir -p /go/src/app
RUN go get github.com/gorilla/mux
WORKDIR /go/src/app
COPY main.go .
RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o main .
我正在尝试将数据库对象传递给我的处理程序,而不是拥有一个全局对象。但我不知道这是否可能,我正在使用Gorilla Mux包,我可以看到它需要一个闭包作为第二个参数。
// https://github.com/gorilla/mux/blob/master/mux.go#L174
// HandleFunc registers a new route with a matcher for the URL path.
// See Route.Path() and Route.HandlerFunc().
func (r *Router) HandleFunc(path string, f fu