I have changes locally in my library golang, that changes I have to test first before push to github repository, my idea is test from another service module and call the library to consume the methods. Can I achieve this ?
Asked
Active
Viewed 560 times
1
-
You are using go modules? – Hamza Anis Aug 27 '20 at 20:58
-
2You can place this peckage inside your service module and test it. – Hamza Anis Aug 27 '20 at 21:08
-
its a tricky right ?, I thought in a solution like gradle install, but im newbee in golang. thanks @HamzaAnis . I'm trying – EdwinCab Aug 27 '20 at 21:15
-
1You can refer to my answer [here](https://stackoverflow.com/questions/52125437/go-module-init-without-vcs-git-fails-with-cannot-determine-module-path/52127799#52127799) and use the package without publishing it on GitHub. – Hamza Anis Aug 28 '20 at 09:58
2 Answers
2
The responses was confuse, for clarify that, I would prefer documenting better my solution:
In the file go.mod, I have to use my local development instead of repository github.com/../../..
We have one step, simply, write replace <github.com/repository> => myLocalFolder
Example:
//go.mod
require (
//this is a repository that I want change
github.com/example/my-reposiory v1.2.0
)
//Here, writing replace, Im achieve use the local code instead of repository code
replace github.com/avaldigitallabs/adl-habilitadora-lib-go-shared-kernel => /Users/<my_user>/Documents/Projects/my_local_folder
//go.mod complete example:
module my-module
go 1.14
require (
github.com/example/my-reposiory v1.2.0
)
replace github.com/example/my-reposiory => /Users/<my_user>/Documents/Projects/my_local_folder

EdwinCab
- 361
- 1
- 3
- 17
-
1`replace` the github module by local module works for me. [modifying-an-imported-library-in-go](https://stackoverflow.com/questions/47516188/modifying-an-imported-library-in-go) – Nick Dong Mar 20 '23 at 04:38
-1
Can I achieve this ?
Yes of course. Just do it. A replace
directive in go.mod might help you.

Volker
- 40,468
- 7
- 81
- 87