0

I want to write a new Go package. If I type go mod init github.com/user/hello, would that be a correct name, if I end up deciding to host it in another location and not github?

Jonathan Hall
  • 75,165
  • 16
  • 143
  • 189
naneri
  • 3,771
  • 2
  • 29
  • 53
  • It doesn't matter. You can use "foo.bar/anything" or "example.org/spam" or whatever you like. – Volker May 25 '21 at 08:34

1 Answers1

1

You can rename the module later, so it plays no important part. Keep using that.

To rename a module in go.mod, you may edit it (it's a simple text file), or you may run the command:

go mod edit -module github.com/newuser/newhello

Note that this will only rename the module in go.mod, but if your module consists of multiple packages which import each other, the import statements will not be edited, you have to manually edit those or use a tool to do that.

If you want to test your module before pushing it to a remote repository, see How to use a module that is outside of "GOPATH" in another module?

icza
  • 389,944
  • 63
  • 907
  • 827