I am trying to build a collections package in Go, and I am having trouble with import paths.
I am modeling the Java Collections interface. Here is my file structure
+/$GOPATH
/bin
/pkg
/src
/github.com
/user
/collections
collections.go
main.go
/collections
/bstAvl
bstAvl.go
My collections.go file looks like this:
package collections
type Collection interface {
Add(interface{}) (bool, error)
AddAll(Collection) (bool, error)
Clear()
Contains(interface{}) (bool, error)
Remove(interface{}) (bool, error)
Size() uint
}
In bstAvl.go
i am trying to use the Collection
interface in Collections.go
How do I import the required package to access the Collection interface?
I think I have gone overboard with the paths, probably made it more complicated than it should be. Is the simpler structure you recommend?
Ideally, I would want all my collections to be under the collections
package so that it could be exported as a library and used in other applications if need be.
P.S I have read Structuring applications in Go by Ben Johnson. But I am still confused. Any help is greatly appreciated.
EDIT: I guess i over worked the package structure. I have decided to stick with this:
+/$GOPATH
/bin
/pkg
/src
/github.com
/user
/collections
collections.go
main.go
bstAvl.go