golang-http-template: Getting `go: inconsistent vendoring` error when a module is located within function
Expected Behaviour
It should work? 🤷♂️
Current Behaviour
Step 17/32 : RUN CGO_ENABLED=${CGO_ENABLED} GOOS=${TARGETOS} GOARCH=${TARGETARCH} go build --ldflags "-s -w" -a -installsuffix cgo -o handler .
---> Running in 56939001fb88
go: inconsistent vendoring in /go/src/handler:
github.com/openfaas/templates-sdk@v0.0.0-20200723092016-0ebf61253625: is explicitly required in go.mod, but not marked as explicit in vendor/modules.txt
handler/function: is replaced in go.mod, but not marked as replaced in vendor/modules.txt
run 'go mod vendor' to sync, or use -mod=mod or -mod=readonly to ignore the vendor directory
The command '/bin/sh -c CGO_ENABLED=${CGO_ENABLED} GOOS=${TARGETOS} GOARCH=${TARGETARCH} go build --ldflags "-s -w" -a -installsuffix cgo -o handler .' returned a non-zero code: 1
[0] < Building notifier-fn done in 2.64s.
[0] Worker done.
Total build time: 2.64s
Errors received during build:
- [notifier-fn] received non-zero exit code from build, error: The command '/bin/sh -c CGO_ENABLED=${CGO_ENABLED} GOOS=${TARGETOS} GOARCH=${TARGETARCH} go build --ldflags "-s -w" -a -installsuffix cgo -o handler .' returned a non-zero code: 1
Steps to Reproduce (for bugs)
We were following the template documentation guide as described here.
$ faas-cli template store pull golang-http$ faas-cli new notifier-fn --lang golang-http --prefix Dentrax$ cd notifier-fn$ go mod init github.com/Dentrax/foo- Use a dependency (i.e. github.com/slack-go/slack) inside
handler.go
Context
go.mod
module github.com/Dentrax/foo
go 1.16
require (
github.com/openfaas/templates-sdk v0.0.0-20200723092016-0ebf61253625
github.com/slack-go/slack v0.8.1
)
notifier-fn.yml:
version: 1.0
provider:
name: openfaas
gateway: http://foo
functions:
notifier-fn:
lang: golang-http
handler: ./notifier-fn
image: Dentrax/notifier-fn:latest
build_args:
GO111MODULE: on
environment:
SLACK_WEBHOOK_URL: https://bar
What we have tried so far that did not work
Each step we applied these in sequential:
-
faas-cli up -f notifier-fn.yml -
faas-cli up -f notifier-fn.yml --build-arg GO111MODULE=on -
Single
handler.gofile: -
$ go mod init ... -
$ go mod vendor+$ go mod tidy? (w/vendordir) -
Using
GO_REPLACE.txtin parent dir
Your Environment
FaaS-CLI version
CLI: commit: 6b5e7a14a598527063c7c05fb4187739b6eb6d38 version: 0.13.6Docker version
Client: Docker Engine - Community Cloud integration: 1.0.7 Version: 20.10.2 API version: 1.41 Go version: go1.13.15 Git commit: 2291f61 Built: Mon Dec 28 16:12:42 2020 OS/Arch: darwin/amd64 Context: default Experimental: trueServer: Docker Engine - Community Engine: Version: 20.10.2 API version: 1.41 (minimum version 1.12) Go version: go1.13.15 Git commit: 8891c58 Built: Mon Dec 28 16:15:28 2020 OS/Arch: linux/amd64 Experimental: false containerd: Version: 1.4.3 GitCommit: 269548fa27e0089a8b8278fc4fc781d7f65a939b runc: Version: 1.0.0-rc92 GitCommit: ff819c7e9184c13b7c2607fe6c30ae19403a7aff docker-init: Version: 0.19.0 GitCommit: de40ad0
-
Are you using Docker Swarm (FaaS-swarm ) or Kubernetes (FaaS-netes)?
NO -
Operating System and version (e.g. Linux, Windows, MacOS):
macOS 11.0.1
We are not sure why the given template documentation does not work as we expected. I think we are missing some important detail on the documentation. Actually, the command that failing above is passing on our local workspace: $ CGO_ENABLED=${CGO_ENABLED} GOOS=${TARGETOS} GOARCH=${TARGETARCH} go build --ldflags "-s -w" -a -installsuffix cgo -o handler . Any ideas?
cc: @developer-guy
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 23 (18 by maintainers)
Fixed by https://github.com/openfaas/golang-http-template/pull/56
@Dentrax i have noticed this issue as well. I ran into it last week, but I have not found a backwards compatible solution. Last weekend when I ran in to the issue, i opted to use the http middleware template instead as a quick fix. But I am still investigating how to fix this template. I need to determine if the middleware template is actually working or just lucky because it doesn’t import any external packages.