1

I am trying to set up a project with a gonum dependency and ran into the problem that we have a corporate proxy that blocks many destinations in the internet.

github.com is available over https. gonum.org is not.

The gonum repository is hosted on github. Gonum.org forwards to it in some way, as the repo that is checked out in gonum.org/v1/gonum is just a github clone. Using the go mod tooling by default will fetch all code, which fails since the github urls are aliased to gonum.org which the proxy will block.

Is there a way to download gonum via github and use symlinks/copying around to still be able to use it?

Wilbert
  • 7,251
  • 6
  • 51
  • 91
  • You'll need to find some way around the firewall, then. Contact your admin, or set up some sort of covert tunnel, or use sneakernet (download on another network, and transfer using a USB stick or similar). This really isn't a programming question. – Jonathan Hall Mar 11 '19 at 09:26
  • @Flimzy The same solution that would work with sneakernet would work with github. The question is about the dependency automation that golang does. It's a question that is probably relevant to some degree to everyone who's coding in go behind a corporate proxy. – Wilbert Mar 11 '19 at 09:59
  • There is no way to automate this, really. The best you can do is manual copying into your vendor folder--or mange your automated vendoring on a machine with full network connectivity. – Jonathan Hall Mar 11 '19 at 10:03
  • @Flimzy vendor folder is dep, but gonum uses go.mod (as far as I understand?) – Wilbert Mar 11 '19 at 10:07
  • I concur with Flimzy: this is not a programming question but rather an infrastructure question. As to `go.mod`, Go modules do support `vendor` directory, too. Also, as a pessimistic fallback, `go.mod` is just a text file with package URIs and versions after all, so, while painstaking, a manual process of bringing in all the required stuff is possible, done by hand. – kostix Mar 11 '19 at 10:09
  • @kostix Which stackexchange site should I ask then? It seems to me this is closely linked to actual golang mechanisms more than unix or linux infrastructure. – Wilbert Mar 11 '19 at 10:11
  • @Wilbert, unfortunately, no: there is simply nothing in the `go` tooling which supports what you're after for (basically, URL rewriting). So you basically have two routes, as discussed in the comments: manual tinkering (with vendoring or go modules (maybe through the use of a dedicated Go module proxy, which do exist)) or working around the administrative stupidity (and there we transgress into the domains of networking or workplace issues). – kostix Mar 11 '19 at 10:15
  • "Which stackexchange site should I ask then?" As far as I know, there isn't one. Just because something isn't on-topic here doesn't mean it's automatically on-topic somewhere else. – Jonathan Hall Mar 11 '19 at 10:26
  • 1
    I don't think it is off-topic. Go modules doc have some instructions to handle this, see the doc: https://github.com/golang/go/wiki/Modules#are-there-always-on-module-repositories-and-enterprise-proxies – Jonathan Muller Mar 11 '19 at 11:13
  • @JonathanMuller, thanks! I'm happy to be corrected on this. – kostix Mar 11 '19 at 13:21

1 Answers1

2

It is possible with go modules. Once you downloaded the gonum sources on your computer, you can tell go to use your local copy instead of the remote one using the replace instruction in your go.mod

Syntax is

module example.com/me/hello

require (
  example.com/me/goodbye v0.0.0
)

replace example.com/me/goodbye => ../goodbye

https://github.com/golang/go/wiki/Modules#can-i-work-entirely-outside-of-vcs-on-my-local-filesystem

It is also possible to setup a proxy outside of your corporate network if the solution given above is not adapted to your team: https://github.com/golang/go/wiki/Modules#are-there-always-on-module-repositories-and-enterprise-proxies

Jonathan Muller
  • 7,348
  • 2
  • 23
  • 31