Skip to content

How can i use go build -mod without default vendor #51308

@180909

Description

@180909

What version of Go are you using (go version)?

$ go version
go version go1.18rc1 darwin/arm64

Does this issue reproduce with the latest release?

What operating system and processor architecture are you using (go env)?

go env Output
$ go env
GO111MODULE="on"
GOARCH="arm64"
GOBIN="/usr/local/go/bin"
GOCACHE="/Users/wang/Library/Caches/go-build"
GOENV="/Users/wang/Library/Application Support/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="arm64"
GOHOSTOS="darwin"
GOINSECURE=""
GOMODCACHE="/Users/wang/go/pkg/mod"
GONOPROXY="gitlab.hexcloud.cn"
GONOSUMDB="gitlab.hexcloud.cn"
GOOS="darwin"
GOPATH="/Users/wang/go"
GOPRIVATE="gitlab.hexcloud.cn"
GOPROXY="https://goproxy.io,direct"
GOROOT="/usr/local/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/darwin_arm64"
GOVCS=""
GOVERSION="go1.18rc1"
GCCGO="gccgo"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/Users/wang/go_project/test/go.mod"
GOWORK=""
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -arch arm64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/fc/5_f38pyn6k915kw7_vvfjhrc0000gn/T/go-build2956473923=/tmp/go-build -gno-record-gcc-switches -fno-common"
GOROOT/bin/go version: go version go1.18rc1 darwin/arm64
GOROOT/bin/go tool compile -V: compile version go1.18rc1
uname -v: Darwin Kernel Version 20.6.0: Mon Aug 30 06:12:20 PDT 2021; root:xnu-7195.141.6~3/RELEASE_ARM64_T8101
ProductName:	macOS
ProductVersion:	11.6
BuildVersion:	20G165
lldb --version: lldb-1300.0.32.2
Swift version 5.5-dev

What did you do?

  1. run go mod vendor -o vendoring on bash
  2. run go build -mod=vendor -o main main.go

What did you expect to see?

No error

What did you see instead?

go: inconsistent vendoring in /Users/x/test:
	github.com/jinzhu/inflection@v1.0.0: is explicitly required in go.mod, but not marked as explicit in vendor/modules.txt
	github.com/jinzhu/now@v1.1.4: is explicitly required in go.mod, but not marked as explicit in vendor/modules.txt
	gorm.io/gorm@v1.23.1: is explicitly required in go.mod, but not marked as explicit in vendor/modules.txt

	To ignore the vendor directory, use -mod=readonly or -mod=mod.
	To sync the vendor directory, run:
		go mod vendor

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions