-1

Let's say I have all source code for module hosted on github.com/example/my-module. But I want to create a proxy hosted on example.com/my-module to redirect all requests to github.com/example/my-module and use my custom domain name in imports:

package main

import "example.com/my-module"

instead of:

package main

import "github.com/example/my-module"

According to docs, I can host git repository on example.com/my-module, but it would be overhead for me.

How can I set up package source code proxy for Go on custom domain? Can I just use HTTP reverse proxy for that or it doesn't work?

Kirill
  • 7,580
  • 6
  • 44
  • 95
  • 2
    No need for a proxy. Just serve appropriate meta tags as described in https://golang.org/cmd/go/#hdr-Remote_import_paths – Volker Oct 20 '20 at 09:09
  • 2
    What Volker said. But you can also study the resuls of [this Internet search engine query](https://www.google.com/search?q=golang+vanity+import+paths). – kostix Oct 20 '20 at 09:16

1 Answers1

1

If you just need it for yourself, or your package's users are open to an extra step to including the package in the go.mod, you could use the "replace" function of the mod file: https://thewebivore.com/using-replace-in-go-mod-to-point-to-your-local-module/

Eaton Emmerich
  • 452
  • 4
  • 17