Module name alias in go.mod
Asked Answered
U

2

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
Ungodly answered 24/4, 2020 at 9:20 Comment(0)
P
12

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

It was proposed but rejected for reasons explained here.

Prescott answered 24/4, 2020 at 9:48 Comment(0)
I
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>

Inversion answered 12/10, 2021 at 20:29 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.