Golang module replace directive equivalent in V? #22127
Unanswered
jorgeluismireles
asked this question in
Questions and Answers
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
My problem
I started a golang project with several gitlab repos, some libraries and some apps. Since all the repos were public any repo could be imported as a library as usual. From app
server.go
:And in server repo we have a
go.mod
like this:Then my employer request me to push all the code to private repositories so libraries could not be imported directly with
go get
orget mod tidy
.My solution
I finally use the replace directive in server app
go.mod
as follows:To use replace, the library now should be read from the filesystem and should be marked as version v0.0.0 (in require directive). This works offline if your code at your station is contigous:
Question 1
What approach is recommended in big V projects and with private repos?
Question 2
In go if your repo is called
gitlab.com/username/protocol-inputs
and you imported, within the code you could access the path with only inputs without protocol part, as an automatic alias. Example:Similarly if your repo is defined as
github.com/gdamore/tcell/v2 v2.6.0
it'll be accessible only withtcell
without any version.Is an equivalent of modules stripped by dashes and versions?
Thanks in advance.
Beta Was this translation helpful? Give feedback.
All reactions