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: document use of nested go.mod files to prune out irrelevant directories #31137

Open
slimjim777 opened this issue Mar 29, 2019 · 8 comments
Labels
Documentation modules NeedsFix The path to resolution is known, but the work has not been done.
Milestone

Comments

@slimjim777
Copy link

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

$ go version
go version go1.12.1 darwin/amd64

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
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/jjesudason/Library/Caches/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/jjesudason/go"
GOPROXY=""
GORACE=""
GOROOT="/usr/local/Cellar/go/1.12.1/libexec"
GOTMPDIR=""
GOTOOLDIR="/usr/local/Cellar/go/1.12.1/libexec/pkg/tool/darwin_amd64"
GCCGO="gccgo"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/dev/null"
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/by/70vkys8x6z7134zfbms06wdc0000gn/T/go-build053664553=/tmp/go-build -gno-record-gcc-switches -fno-common"

What did you do?

  1. Create an application that uses github.com/snapcore/snapd as an import
  2. Run: go mod tidy
go mod tidy
go: finding github.com/snapcore/snapd/asserts latest
go: finding github.com/snapcore/snapd latest
go: extracting github.com/snapcore/snapd v0.0.0-20190329093636-71bdfa33d159
-> unzip /Users/jjesudason/go/pkg/mod/cache/download/github.com/snapcore/snapd/@v/v0.0.0-20190329093636-71bdfa33d159.zip: malformed file path "cmd/snap-confine/spread-tests/distros/debian.": trailing dot in path element

What did you expect to see?

Expected to see the package fetched successfully

What did you see instead?

go modules choke on some filenames that it does not like, even though they are no Go files and have no relevance to the app/package compilation

@slimjim777
Copy link
Author

This is another example of a filename that fails:

go: finding github.com/slimjim777/snapd/asserts latest
go: finding github.com/slimjim777/snapd latest
go: extracting github.com/slimjim777/snapd v0.0.0-20190329103353-c1ea86c7084a
-> unzip /Users/jjesudason/go/pkg/mod/cache/download/github.com/slimjim777/snapd/@v/v0.0.0-20190329103353-c1ea86c7084a.zip: malformed file path "tests/completion/data/twisted/this isn't.innit": invalid char '\''

@agnivade
Copy link
Contributor

@bcmills this is coming up pretty frequently now.

#28001 (comment)

Shall we do something about it ?

@bcmills
Copy link
Contributor

bcmills commented Mar 29, 2019

@agnivade We can look at specific characters, but in general we cannot allow non-portable filenames within modules.

If there are parts of the repository that should not be included in the module at all, you can always cut them off by adding another go.mod file in the directory tree.

@slimjim777
Copy link
Author

If there are parts of the repository that should not be included in the module at all, you can always cut them off by adding another go.mod file in the directory tree.

@bcmills that's interesting - could clarify how to do that? The exclude directive seems to be aimed at excluding sub-dependencies rather than a specific directory. Also, the files that are causing go mod to fail are not actually Go files, so potentially they could be excluded by default.

@bcmills
Copy link
Contributor

bcmills commented Mar 29, 2019

@thepudds, @myitcv: Are you aware of any documentation on using go.mod files to prune a repository?

I'm not having any luck finding it, so I'm going to retitle the issue to focus on that part (since there's not much we can plausibly do about the rest).

@bcmills bcmills changed the title go modules fails on non-go file names cmd/go: document use of nested go.mod files to prune out irrelevant directories Mar 29, 2019
@bcmills bcmills added this to the Go1.13 milestone Mar 29, 2019
@bcmills
Copy link
Contributor

bcmills commented Mar 29, 2019

@slimjim777, you should be able to just drop in an empty go.mod file at the topmost directory whose contents are irrelevant to the Go packages. So perhaps:

$ touch cmd/snap-confine/go.mod

@myitcv
Copy link
Member

myitcv commented Mar 29, 2019

Are you aware of any documentation on using go.mod files to prune a repository?

@bcmills - I am not, no. But to be honest I would have deferred to @thepudds in any case 😄

@slimjim777
Copy link
Author

@slimjim777, you should be able to just drop in an empty go.mod file at the topmost directory whose contents are irrelevant to the Go packages. So perhaps:

$ touch cmd/snap-confine/go.mod

Thanks - I'll create a PR for that project.

Then docs that I've found are: https://github.com/golang/go/wiki/Modules

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Documentation modules NeedsFix The path to resolution is known, but the work has not been done.
Projects
None yet
Development

No branches or pull requests

7 participants