去获取没有互联网访问权限的服务器

Our server can not connect to the Internet because of security lock down.

To be able to use GO with 3rd party modules, I see that we have to options

1) Our laptops can connect to the internet. Is it possible to "go get github...." on the laptop and then copy that module to the server? How would we do this?

2) We have a GOGS server on the network. Would it be possible to clone the github repository and then push it as a private repository to the GOGS server? What changes do we need to make to the GO configuration? (This would be the preferred option if it is possible)

  1. Most probably all the sources of all your projects and all external libraries are inside a $GOPATH dir. Just sync needed folders and you are done.

  2. Yes, that is possible. After pushing a Github repo clone to your Gogs server - all you need to do is to import a package (go get) from new location and in your sources you have to replace "github.com" with what you have, something like "gogs.local":

import "gogs.local/username/packagename"

You should use Godep, a dependency tool for go.

How to use godep with a new project

Assuming you've got everything working already, so you can build your project with go install and test it with go test, it's one command to start using:

$ godep save

This will save a list of dependencies to the file Godeps/Godeps.json and copy their source code into vendor/

So you will have inside your project the dependencies (if you do those steps in your development machine).


Github: github.com/tools/godep