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

Review incorrect go module usage #43

Closed
cep21 opened this issue Jul 12, 2019 · 3 comments
Closed

Review incorrect go module usage #43

cep21 opened this issue Jul 12, 2019 · 3 comments

Comments

@cep21
Copy link

cep21 commented Jul 12, 2019

Hi,

I ran into the following issue using this client with go and modules.

build github.com/my/service: cannot load github.com/cactus/go-statsd-client/statsd: ambiguous import: found github.com/cactus/go-statsd-client/statsd in multiple modules:
    github.com/cactus/go-statsd-client v3.1.1+incompatible (/Users/jlindamo/go/pkg/mod/github.com/cactus/go-statsd-client@v3.1.1+incompatible/statsd)
    github.com/cactus/go-statsd-client/statsd v0.0.0-20190501063751-9a7692639588 (/Users/jlindamo/go/pkg/mod/github.com/cactus/go-statsd-client/statsd@v0.0.0-20190501063751-9a7692639588)

This doesn't happen if you're directly referencing this client, but can if multiple libraries are referencing the client in different ways and you're trying to use both libraries at once.

I don't think the change to add the go.mod file was correct: https://github.com/cactus/go-statsd-client/blob/master/statsd/go.mod

With go.mod, since you're on tag v3, the path of everything inside there should be github.com/cactus/go-statsd-client/statsd/v3 instead of github.com/cactus/go-statsd-client/statsd. That includes the go.mod file as well.

It may be best to either add v3 to the path in the module file, or remove the go.mod file.

@cep21
Copy link
Author

cep21 commented Jul 12, 2019

CC: @manaspaldhe12

@dropwhile
Copy link
Member

There is some unclear documentation on the go site in regards to the placement of go.mod.
For example, this documentation wiki makes it sound like like even though the go-statsd-client is never used as a top level import (eg. import "github.com/cactus/go-statsd-client") that the go.mod should go at the top level anyway. That's a bit strange...

This page seems to present conflicting information:

A module is defined by a tree of Go source files with a go.mod file in the tree's root directory. The directory containing the go.mod file is called the module root. Typically the module root will also correspond to a source code repository root (but in general it need not). The module is the set of all Go packages in the module root and its subdirectories, but excluding subtrees with their own go.mod files.

Perhaps you can post the go.mod for the project that raised the error?
Maybe that go.mod file has a dep pinned for github.com/cactus/go-statsd-client instead of for github.com/cactus/go-statsd-client/statsd?

@dropwhile
Copy link
Member

no feedback. closing for now. reopen if needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants