Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can golang import package from private subversion repository?

Tags:

git

svn

go

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...
}
like image 856
Tony Bai Avatar asked Oct 24 '12 08:10

Tony Bai


People also ask

Does Go get use Git?

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.

Can you use Git for Subversion?

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.


2 Answers

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

like image 147
ffel Avatar answered Sep 30 '22 03:09

ffel


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.

like image 36
Doug Avatar answered Sep 30 '22 02:09

Doug