据我了解,golang 导入模块如
import (
"bitbucket.org/user/project"
"github.com/user/project"
)
有没有办法在所有文件中导入模块,而无需显式输入绝对远程位置,从
1) 一个远程位置?
2)多个地点?
因此对于 1),您可以在某处指定主机为 github.com/user,并且任何不是默认库且没有远程前缀的导入都以 github.com/user 为前缀。或者有一个 prefix_variable + relative/path 并且能够在某处设置 prefix_variable?
所以喜欢
// in some config file
github = "github.com/user/"
bitbucket = "bitbucket.org/user/"
// imported in file
import (
bitbucket + "project" // "bitbucket.org/user/project"
github + "project" // "github.com/user/project"
)
或者
// in some config file
default = "github.com/user"
// imported in file
import (
"bitbucket.org/user/project" // this has a remote prefix, so default prefix is not added
"project" // "github.com/user/project"
)