0
我想在Go中构建一个集合包,并且导入路径遇到问题。导入程序包中的路径问题
我正在建模Java Collections界面。这里是我的文件结构
+/$GOPATH
/bin
/pkg
/src
/github.com
/user
/collections
collections.go
main.go
/collections
/bstAvl
bstAvl.go
我collections.go文件看起来像这样:
package collections
type Collection interface {
Add(interface{}) (bool, error)
AddAll(Collection) (bool, error)
Clear()
Contains(interface{}) (bool, error)
Remove(interface{}) (bool, error)
Size() uint
}
在bstAvl.go
我试图使用Collection
接口Collections.go
如何导入所需包访问Collection界面?
我觉得我已经走上了路径,可能会让它变得比它应该更复杂。您推荐的结构更简单吗?
理想情况下,我希望我所有的集合都在collections
包下,以便它可以作为库导出并在需要时用于其他应用程序。
P.S我已阅读Structuring applications in Go by Ben Johnson。但我仍然感到困惑。任何帮助是极大的赞赏。
编辑: 我想我过去的包装结构。我决定坚持这一点:
+/$GOPATH
/bin
/pkg
/src
/github.com
/user
/collections
collections.go
main.go
bstAvl.go