Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmd/go: does go module support ignoring one sub-directory? #31584

Open
andyliuliming opened this issue Apr 20, 2019 · 1 comment

Comments

Projects
None yet
2 participants
@andyliuliming
Copy link

commented Apr 20, 2019

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

go1.12.4

$ go version

Does this issue reproduce with the latest release?

yes

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

go env Output
$ go env


fGOARCH="amd64"
GOBIN=""
GOCACHE="/Users/andy/Library/Caches/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/andy/workspace/gopath"
GOPROXY=""
GORACE=""
GOROOT="/usr/local/Cellar/go/1.12.4/libexec"
GOTMPDIR=""
GOTOOLDIR="/usr/local/Cellar/go/1.12.4/libexec/pkg/tool/darwin_amd64"
GCCGO="gccgo"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD=""
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/cg/3770ch_93sj65nvnr6t4rbtm0000gn/T/go-build670995852=/tmp/go-build -gno-record-gcc-switches -fno-common"

What did you do?

we need to use a sub-directory called
"test" and the sub-directory contains one Gopkg.toml itself.
and it works in the dep tool.
but after we're trying to switch to use go module. then go mod will scans the "test" folder for us, and some extra(expecially the incompatable packages) are added automatically.
is there one way to put some ignorant logic into the go mod tidy or scanning logic here?

What did you expect to see?

What did you see instead?

@andyliuliming andyliuliming changed the title does go module support ignore one sub-directory? does go module support ignoring one sub-directory? Apr 21, 2019

@andyliuliming andyliuliming changed the title does go module support ignoring one sub-directory? cmd/go does go module support ignoring one sub-directory? Apr 22, 2019

@andyliuliming andyliuliming changed the title cmd/go does go module support ignoring one sub-directory? cmd/go: does go module support ignoring one sub-directory? Apr 22, 2019

@thepudds

This comment has been minimized.

Copy link

commented Apr 22, 2019

The simplest solution might be to rename the directory to something with a leading _, such as _examples or similar. By default, the go tool does not descend into subdirectories with a leading _.

From https://golang.org/cmd/go/#hdr-Package_lists_and_patterns

Directory and file names that begin with "." or "_" are ignored by the go tool, as are directories named "testdata".

Do you think that would work for you?

Alternatively, you could place a new separate go.mod in the subdirectory, but that can have some nuances and might be better to start with a simpler solution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.