Chris G.
Chris G.

Reputation: 25934

Module name alias in go.mod

Is there a way to use a shorter name representation/mapping in modules?

I have a project, with an url naming:

module github.com/<org>/<project>    
go 1.14

Would be nice to be able to do:

import "<short_name>/<project>/package_folder"

From a go.mod, something like:

module github.com/<org>/<project> => short_name
go 1.14

Upvotes: 8

Views: 9756

Answers (2)

user293390
user293390

Reputation: 21

I've run into this recently with a poorly named internal repo. Go doesn't do this, but with some git magic you can get close.

In your ~/.gitconfig add something like this: [url "ssh://[email protected]//"] insteadOf = https://github.com/<go_mod_org>/<go_mod_repo>

Upvotes: 2

ifnotak
ifnotak

Reputation: 4662

Nope, there is no way to define an alias in the go.mod file.

It was proposed but rejected for reasons explained here.

Upvotes: 12

Related Questions