On Wed, 8 Sept 2021, 5:34 am Dean Schulze, <dean.w.schu...@gmail.com> wrote:
> If you are going to publish a Go module does the module name have to > include the repo name? I couldn't find this documented anywhere but > through trial and error I've discovered that it is required. > > I named my module like this and published it to github: > > *module key-value-mod* > > In another module I declared it to be a dependency > > *require github.com/dwschulze/key-value-mod > <http://github.com/dwschulze/key-value-mod> v0.1.0* > > When I ran *go get* I got this error: > > *$ go get github.com/dwschulze/key-value-mod@v0.1.0 > <http://github.com/dwschulze/key-value-mod@v0.1.0>* > *go: github.com/dwschulze/key-value-mod@v0.1.0 > <http://github.com/dwschulze/key-value-mod@v0.1.0>: parsing go.mod:* > * module declares its path as: key-value-mod* > * but was required as: github.com/dwschulze/key-value-mod > <http://github.com/dwschulze/key-value-mod>* > > I changed the module's name to include the repo (and retagged that commit > and pushed both) > > *module github.com/dwschulze/key-value-mod > <http://github.com/dwschulze/key-value-mod>* > > and then it worked. > > This is a private repo if that makes any difference. > > I also discovered that when you have module problems like this you have to > clear the mod cache or you end up getting the same error over and over > again. > I came to this conclusion the same way as you did via trial and error. The go.mod of your module must match its location on the Internet/Network when you are importing it from another module. > > -- > You received this message because you are subscribed to the Google Groups > "golang-nuts" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to golang-nuts+unsubscr...@googlegroups.com. > To view this discussion on the web visit > https://groups.google.com/d/msgid/golang-nuts/d7c5cc18-6c54-4379-92fe-f313a2c5bc01n%40googlegroups.com > <https://groups.google.com/d/msgid/golang-nuts/d7c5cc18-6c54-4379-92fe-f313a2c5bc01n%40googlegroups.com?utm_medium=email&utm_source=footer> > . > -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/CANODV3kq7t21Bw3XSb9TV_4_m%2Bwns4U4WKOrG5UVJgwcbiRJ9g%40mail.gmail.com.