Importing all external golang modules to one file and then importing from that file?

huangapple go评论144阅读模式
英文:

Importing all external golang modules to one file and then importing from that file?

问题

有没有一种方法可以将外部模块导入到一个文件中,然后从该文件中导入?

例如:

// externals.go
import ( 
  Bitbucket "bitbucket.org/user/project"
  Github "github.com/user/project"
)

// main.go
import (
  "externals/Bitbucket"
  "externals/Github"
)

以上的形式是否可行?

英文:

Is there a way to import external modules into one file and then import from that file?

For example:

// externals.go
import ( 
  Bitbucket "bitbucket.org/user/project"
  Github "github.com/user/project"
)

// main.go
import (
  "externals/Bitbucket"
  "externals/Github"
)

Is the above in some form possible?

答案1

得分: 1

不,这是不可能的。Go语言的一个特定设计目标是使所有依赖关系都明确可见。

请参阅http://talks.golang.org/2012/splash.article,特别是第7节,以获取更多详细信息。

英文:

No, this is not possible. It is a specific design goal of Go
to make all dependencies explicit.

See http://talks.golang.org/2012/splash.article and section 7
in particular for more detail on this.

答案2

得分: 0

不,这是不可能的,即使使用一些技巧也不行。

英文:

No. This is not possible, not even with some tricks.

huangapple
  • 本文由 发表于 2013年9月20日 11:13:03
  • 转载请务必保留本文链接:https://go.coder-hub.com/18908247.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定