lxc / go-lxc

Go bindings for liblxc
https://linuxcontainers.org/lxc
Other
428 stars 77 forks source link

Import path to gopkg.in/lxc/go-lxc.v2 breaks module replacement #155

Closed r10r closed 3 years ago

r10r commented 3 years ago

Hi there,

I noticed that the import path gopkg.in/lxc/go-lxc.v2 (proposed by the readme) breaks module replacement.

I used the import path gopkg.in/lxc/go-lxc.v2 in lxcri. E.g to test lxcri against a development go-lxc remote branch I change the import path in go.mod:

replace gopkg.in/lxc/go-lxc.v2 => github.com/drachenfels-de/go-lxc fixes

When refreshing go.mod I get the following error:

[ruben@k8s-cluster8-controller lxcri]$ go get -u -v gopkg.in/lxc/go-lxc.v2
go: gopkg.in/lxc/go-lxc.v2@v2.0.0-20210205143421-c4b883be4881 (replaced by github.com/drachenfels-de/go-lxc@v0.0.0-20210525103000-70dfb1ce8a2b): parsing go.mod:
    module declares its path as: github.com/lxc/go-lxc
            but was required as: gopkg.in/lxc/go-lxc.v2

After changing the import path to github.com/lxc/go-lxc the following module replacement works fine.

replace github.com/lxc/go-lxc => github.com/drachenfels-de/go-lxc fixes

What about changing all gopkg.in/go-lxc.v2 references in README.md to github.com/go-lxc ?

stgraber commented 3 years ago

Does that work properly with pre-gomod setups? I thought we had to use gopkg.in because we couldn't have Go import from a branch prior to go modules becoming a thing.

r10r commented 3 years ago

Changing the README shouldn't affect pre-gomod setups unless someone decides to update the import itself. But I think new projects should definitely use github.com/lxc/go-lxc as import. I noticed that you have already changed the import path of the examples in https://github.com/lxc/go-lxc/commit/e866d78e65486b1ef02445169d9ce6391dccf13a What about adding a notice then ? e.g

Use gopkg.in/lxc/go-lxc.v2 instead if you do not use go modules.`

stgraber commented 3 years ago

Oh sorry, wasn't very awake this morning. Yeah, README is fine too update, there are very few people who won't be using go mod and those will know what to do anyway.

r10r commented 3 years ago

Well, I'll send a pull request then.

r10r commented 3 years ago

Thanks for merging!