8

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

2 Answers 2

12

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

It was proposed but rejected for reasons explained here.

0
2

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>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.