Skip to content

Getting go: inconsistent vendoring error when a module is located within function #55

Closed
@Dentrax

Description

@Dentrax

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/[email protected]: 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.

  1. $ faas-cli template store pull golang-http
  2. $ faas-cli new notifier-fn --lang golang-http --prefix Dentrax
  3. $ cd notifier-fn
  4. $ go mod init github.com/Dentrax/foo
  5. 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.go file:

  • $ go mod init ...

  • $ go mod vendor + $ go mod tidy? (w/ vendor dir)

  • Using GO_REPLACE.txt in parent dir

Your Environment

FaaS-CLI version CLI: commit: 6b5e7a14a598527063c7c05fb4187739b6eb6d38 version: 0.13.6
Docker 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: true

Server: 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions