引用库中的另一个.go文件

I am very new to Go and I have gone through How to Write Go Code

While it was very helpful, I'm confused about how to use a go file from within the same library.

For example, this is my structure :

~/src/
    hashtable/
      hashtable.go
      linkedlist.go

I want to use linkedlist in hashtable. What should be my directory structure and what package names should I use?

In Go, two or more files with the same package name are considered one package, meaning everything is accessible within the namespace, including private (lowercased) and public (capitalized) symbols.

For instance, if hashtable.go and linkedlist.go share the same package name:

package hashtable

import (
        ...
)

Then both are considered the same file.

However, if they have different package name, the best practice is to keep them in separate directory.

// hashtable.go
package hashtable

import (
        ...
)

type Hashtable struct {}

// linkedlist.go
package linkedlist
import (
        ...
)

type Linkedlist struct {}

Then organizing them this way:

project/
├── hashtable
|   └── hashtable.go
└── linkedlist
    └── linkedlist.go

And for example, in hashtable.go, import linkedlist to use its public variables:

// hashtable.go
package hashtable

import (
        ../linkedlist
)

li = linkedlist.Linkedlist{}