Keeping self-referencing URLs outside of module's code

94 views
Skip to first unread message

Slawomir Pryczek

unread,
Jul 13, 2022, 5:06:03 AM7/13/22
to golang-nuts
Hi Guys, have a golang module with multiple sub-modules, which i want to use "properly" in some other projects.

The issue is that the path is very long as that module is a part of a bigger project and it's inconvinient to repeat it everywhere over and over.


1. So the first idea was just to put handler_socket2 instead of the path inside go.mod. Everything was working correctly within the module, but it produced issue during import: "module declares its path as: handler_socket2 but was required as: github.com/slawomir-pryczek/HSServer/go/src/handler_socket2". Is it possible to get rid of this somehow? So if people will write some module and decide to publish it later they can just publish it without modifying half of their projects files?

2. The second idea was to declare the module with "proper" path, but replace handler_socket2 with ../handler_socket2 (link below). 


Which again produces an error during import:
go: github.com/slawomir-pryczek/HSServer/go/src/handler...@v0.0.0-20220713073931-8de251cbe13e requires handler...@v0.0.0: malformed module path "handler_socket2": missing dot in first path element

So is there any way of not including self-referencing github URL over and over again if you just want to reference the sub-module of the module you're in? It's like writing a website and including local, absolute server paths for every image. Then if i want to fork a module or create v2 it'll get a different URL and i'll have to edit almost everything, which again will make the forked code to have to include unneeded changes vs the base.

Thanks
Reply all
Reply to author
Forward
0 new messages