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

Drop dependency on subpackage #123

Closed
wants to merge 1 commit into from

Conversation

DavidHuie
Copy link

This project had a dependency on github.com/ugorji/go/codec which is a subpackage of the Go modules project github.com/ugorji/go. This causes this error when trying to use this package in other Go modules projects:

cannot load github.com/ugorji/go/codec: ambiguous import: found github.com/ugorji/go/codec in multiple modules:
        github.com/ugorji/go v1.1.4 (/Users/david/pkg/mod/github.com/ugorji/[email protected]/codec)
        github.com/ugorji/go/codec v0.0.0-20181209151446-772ced7fd4c2 (/Users/david/pkg/mod/github.com/ugorji/go/[email protected])

@mattheworiordan
Copy link
Member

mattheworiordan commented Apr 15, 2019

Thanks @DavidHuie for the PR. We'll get one of the Go devs to take a look, but LGTM

@gernest
Copy link
Contributor

gernest commented Apr 19, 2019

@DavidHuie I took a look at this PR. I was trying to reproduce the issue you mentioned above through the following steps

mkdir test-ably
cd test-ably
go mod init github.com/gernest/test-ably
touch test.go

Then I added content to test.go

$ cat test.go 
package xt

import (
        "github.com/ably/ably-go/ably"
)

var _ = ably.AblyClientIDHeader

To make sure I don't miss anything

touch test_test.go
$ cat test_test.go 
package xt

import (
        "testing"

        "github.com/ably/ably-go/ably"
)

func Test(t *testing.T) {
        t.Log(ably.AblyClientIDHeader)
}

Then I ran the tidy command to add packages

go mod tidy

No errors were reported

And here is is the contents of go.mod and go.sum

$ cat go.mod 
module github.com/gernest/test-ably

go 1.12

require github.com/ably/ably-go v1.1.1
$ cat go.sum 
github.com/ably/ably-go v1.1.1 h1:tTBfvls2+010cbFZbl11nP+jWgBgKujgm1ZRpWawTMk=
github.com/ably/ably-go v1.1.1/go.mod h1:rxAdoiP+Wr3RxbHsQDSxYaq/2HWEko0+phccTzDf7MA=github.com/ugorji/go/codec v0.0.0-20181209151446-772ced7fd4c2 h1:EICbibRW4JNKMcY+LsWmuwob+CR
S1BmdRdjphAm9mH4=github.com/ugorji/go/codec v0.0.0-20181209151446-772ced7fd4c2/go.mod h1:VFNgLljTbGfSG7qAOspJ
7OScBnGdDN/yBr0sguwnwf0=golang.org/x/net v0.0.0-20190110200230-915654e7eabc h1:Yx9JGxI1SBhVLFjpAkWMaO1TF+xyqtHLjZpvQ
boJGiM=
golang.org/x/net v0.0.0-20190110200230-915654e7eabc/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=

From the steps I outlined above, I haven't been successful able to reproduce your issue. I might have missed something though.

If you don't mind can you please help me reproduce it, that way I can be able to review this PR properly and make sure it resolve the issue.

@xshyne88
Copy link

xshyne88 commented Mar 9, 2020

@QuintinWillison

I think this needs to be reopened though I think the OP did not mention that this error happens when you have other dependencies such as https://github.com/spf13/viper. (Also seems etcd, and gin-gonic would also be in conflict).

Here is a link to the codec packages solution.
ugorji/go#299

DataDog forked viper and made this exact change in a commit, here is what they did:
DataDog/viper@2922e44

Thanks for taking a look.

@QuintinWillison
Copy link
Contributor

Thanks @xshyne88 - we'll take another look. I've opened an issue for now to track this as we're soon embarking on another tranche of work on this library.

Out of interest, are you seeing exactly the same problem or something different but perhaps related?

@xshyne88
Copy link

xshyne88 commented Mar 9, 2020

Here is my error trace:

/Users/chase/.go/pkg/mod/github.com/ably/[email protected]/ably/proto/message.go:12:2: ambiguous import: found github.com/ugorji/go/codec in multiple modules:
	github.com/ugorji/go v1.1.4 (/Users/chase/.go/pkg/mod/github.com/ugorji/[email protected]/codec)
	github.com/ugorji/go/codec v0.0.0-20181209151446-772ced7fd4c2 (/Users/chase/.go/pkg/mod/github.com/ugorji/go/[email protected])

I think it's the same problem. I spent some time trying to debug this, this morning, as the library and my tests were working fine on Friday. As soon as I pulled the repo, and the viper dependency was added this started happening. That's about as much context as I have.

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

Successfully merging this pull request may close these issues.

5 participants