diff --git a/template/go/Dockerfile b/template/go/Dockerfile index 37078ac4..8410a980 100644 --- a/template/go/Dockerfile +++ b/template/go/Dockerfile @@ -1,5 +1,5 @@ FROM --platform=${TARGETPLATFORM:-linux/amd64} ghcr.io/openfaas/classic-watchdog:0.2.0 as watchdog -FROM --platform=${BUILDPLATFORM:-linux/amd64} golang:1.17-alpine3.15 as builder +FROM --platform=${BUILDPLATFORM:-linux/amd64} golang:1.18-alpine3.15 as builder ARG TARGETPLATFORM ARG BUILDPLATFORM @@ -24,13 +24,11 @@ ENV CGO_ENABLED=0 WORKDIR /go/src/handler COPY . . -# Add user overrides to the root go.mod, which is the only place "replace" can be used -RUN cat function/GO_REPLACE.txt >> ./go.mod || exit 0 - # Run a gofmt and exclude all vendored code. RUN test -z "$(gofmt -l $(find . -type f -name '*.go' -not -path "./vendor/*" -not -path "./function/vendor/*"))" || { echo "Run \"gofmt -s -w\" on your Golang code"; exit 1; } WORKDIR /go/src/handler/function +RUN go env RUN GOOS=${TARGETOS} GOARCH=${TARGETARCH} CGO_ENABLED=${CGO_ENABLED} go test ./... -cover diff --git a/template/go/function/go.mod b/template/go/function/go.mod new file mode 100644 index 00000000..45f94acf --- /dev/null +++ b/template/go/function/go.mod @@ -0,0 +1,3 @@ +module handler/function + +go 1.18 diff --git a/template/go/go.mod b/template/go/go.mod index 64342319..34496254 100644 --- a/template/go/go.mod +++ b/template/go/go.mod @@ -1,5 +1,3 @@ module handler -go 1.16 - -replace handler/function => ./function +go 1.18 diff --git a/template/go/go.work b/template/go/go.work new file mode 100644 index 00000000..8f6f1658 --- /dev/null +++ b/template/go/go.work @@ -0,0 +1,6 @@ +go 1.18 + +use ( + . + ./function +)