Friday, October 4, 2024
HomeGolangImport dependiencies from the identical package deal - Getting Assist

Import dependiencies from the identical package deal – Getting Assist


even thou we’ve got the identical package deal however completely different information do we have to have public structs, components and many others?
e.g
core/utils/utils.go

package deal core
some code

core/methods/fifo.go

package deal core
import core "imc/core"

and many others

core/utils/utils.go belongs to the core/utils/core package deal
core/methods/fifo.go belongs to the core/methods/core package deal

Though they’re usually referred to easily as core packages, they’re truly two completely different packages, so there is no such thing as a such factor as sharing

@peakedshout so seems like we have to present unique package deal title for every .go file in the case of completely different folders?
right me if i’m unsuitable – “core/utils/utils.go” ought to have some distinctive package deal title (e.g. ” utils”) after which we have to present import for this package deal?

I believe you must systematically study GO’s package deal administration system. Usually talking, go information in the identical listing belong to the identical package deal and share non-public variables, features, and so forth. Nested subdirectories or go information of subdirectories don’t rely. Cross-package references can solely reference public features, variables, and many others., that are uncovered to the package deal, which usually begins with uppercase.

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments