简体   繁体   中英

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

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

It was proposed but rejected for reasons explained here .

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://git@github.com//"] insteadOf = https://github.com/ <go_mod_org>/<go_mod_repo>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM