From 38eb9b95967fee9af3f8fe2c9c961817db671af1 Mon Sep 17 00:00:00 2001 From: Carlos Panato Date: Wed, 3 Nov 2021 18:03:52 +0100 Subject: [PATCH] default go module to on Signed-off-by: Carlos Panato --- README.md | 8 ++++---- template/golang-http/template.yml | 4 ++-- template/golang-middleware/Dockerfile | 2 +- template/golang-middleware/template.yml | 4 ++-- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 292ab39..90dc657 100644 --- a/README.md +++ b/README.md @@ -27,8 +27,8 @@ The two templates are equivalent with `golang-http` using a structured request/r You can manage dependencies in one of the following ways: -* To use Go modules without vendoring, add `--build-arg GO111MODULE=on` to `faas-cli up`, you can also use `--build-arg GOPROXY=https://` if you want to use your own mirror for the modules -* You can also Go modules with vendoring, run `go mod vendor` in your function folder and add `--build-arg GO111MODULE=on` to `faas-cli up` +* To use Go modules without vendoring, the default already is set `GO111MODULE=on` but you also can make that explicity by adding `--build-arg GO111MODULE=on` to `faas-cli up`, you can also use `--build-arg GOPROXY=https://` if you want to use your own mirror for the modules +* You can also Go modules with vendoring, run `go mod vendor` in your function folder and add `--build-arg GO111MODULE=off` to `faas-cli up` * For traditional vendoring with `dep` give no argument, or add `--build-arg GO111MODULE=off` to `faas-cli up` ## 1.0 golang-http @@ -394,8 +394,6 @@ This replacement is handled gracefully by the template at build time and your lo ##### Go sub-modules -For this example you will need to be using Go 1.13 or newer and Go modules, enable this via `faas-cli build --build-arg GO111MODULE=on`. - Imagine you have a package which you want to store outside of the `handler.go` file, it's another middleware which can perform an echo of the user's input. ```Golang @@ -439,3 +437,5 @@ func Handle(w http.ResponseWriter, r *http.Request) { handlers.Echo(w, r) } ``` + +If you have any vendor private dependency, you can disable the Go module via `faas-cli build --build-arg GO111MODULE=off`. diff --git a/template/golang-http/template.yml b/template/golang-http/template.yml index f40f1c7..92d9766 100644 --- a/template/golang-http/template.yml +++ b/template/golang-http/template.yml @@ -3,8 +3,8 @@ fprocess: ./handler welcome_message: | You have created a new function which uses Go 1.16. - To include third-party dependencies, use Go modules and use - "--build-arg GO111MODULE=on" with faas-cli build or configure this + To disable the go module, for private vendor code, please use + "--build-arg GO111MODULE=off" with faas-cli build or configure this via your stack.yml file. See more: https://docs.openfaas.com/cli/templates/ diff --git a/template/golang-middleware/Dockerfile b/template/golang-middleware/Dockerfile index 54fece1..7853c2e 100644 --- a/template/golang-middleware/Dockerfile +++ b/template/golang-middleware/Dockerfile @@ -17,7 +17,7 @@ RUN mkdir -p /go/src/handler WORKDIR /go/src/handler COPY . . -ARG GO111MODULE="off" +ARG GO111MODULE="on" ARG GOPROXY="" ARG GOFLAGS="" ARG DEBUG=0 diff --git a/template/golang-middleware/template.yml b/template/golang-middleware/template.yml index 32f4c97..ba065ca 100644 --- a/template/golang-middleware/template.yml +++ b/template/golang-middleware/template.yml @@ -3,8 +3,8 @@ fprocess: ./handler welcome_message: | You have created a new function which uses Go 1.16. - To include third-party dependencies, use Go modules and use - "--build-arg GO111MODULE=on" with faas-cli build or configure this + To disable the go module, for private vendor code, please use + "--build-arg GO111MODULE=off" with faas-cli build or configure this via your stack.yml file. See more: https://docs.openfaas.com/cli/templates/