Import dependiencies from the same package

even thou we have the same package but different files do we need to have public structs, elements etc?
e.g
core/utils/utils.go

package core
some code

core/strategies/fifo.go

package core
import core "imc/core"

etc

core/utils/utils.go belongs to the core/utils/core package
core/strategies/fifo.go belongs to the core/strategies/core package

Although they are generally referred to simply as core packages, they are actually two different packages, so there is no such thing as sharing

@peakedshout so looks like we need to provide exclusive package name for each .go file when it comes to different folders?
correct me if i’m wrong - “core/utils/utils.go” should have some unique package name (e.g. " utils") and then we need to provide import for this package?

I think you should systematically learn GO’s package management system. Generally speaking, go files in the same directory belong to the same package and share private variables, functions, and so on. Nested subdirectories or go files of subdirectories do not count. Cross-package references can only reference public functions, variables, etc., which are exposed to the package, which generally starts with uppercase.

1 Like