As we know golang support import package from famous code hosted sites, such as github,google code and so on, but what I would like to figure out is whether golang support import package from my private subversion/git repository? It would become easier to share some common package among projects if golang support this.
an ideal example:
package main
import "192.168.12.13/trunk/share/foolib"
func main() {
....
foolib.xxxx...
}
In Go, you can use the get command to download and install packages and dependencies. Azure Repos Git provides support for go get within an Azure Repos Git repository. With go get , you will be able to download packages with their dependencies named by the import paths.
git svn is a git command that allows using git to interact with Subversion repositories. git svn is part of git, meaning that is NOT a plugin but actually bundled with your git installation. SourceTree also happens to support this command so you can use it with your usual workflow.
yes, you can import code from private repositories, run go help importpath
for instructions.
this is, however, a two phase approach: first get the code, than compile it into your project.
your example suggests that you want to import remote code (so, a one phase process essentially), I doubt that is possible
If it's a private repository, you're almost certainly better off managing this manually.
For subversion use a subversion external; for git use a submodule, etc.
go get ...
Is a helpful tool, but you'll probably run into difficulty once you start using closed signed internal repositories; since most non-stupid source control already supports this type of 'submodule' like functionality, you're probably better off using the facilities of whatever source control you use and importing your custom submodules into your 'src' directory, and then, as above, importing using:
import mylib "modules/xxx/trunk/src/blah"
...rather than trying to force go get to do all the things all of the time.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With