Monday, June 16, 2025
HomeGolangNot capable of import capabilities - Getting Assist

Not capable of import capabilities – Getting Assist


Whats up,
I’m going through subject whereas importing perform. I’ve the listing construction as talked about within the screenshot.
I need to import perform “handlerReadiness” from handler_readiness.go into major.go. However after I run the primary.go file, it says “undefined handlerReadiness”.
Though after I hover over handlerReadiness, I can see the perform in outlined and may attain to it’s definition by doing command+click on.

Please assist in resolving this subject.

View the handler_readiness.go file.

Lowercase names imply “non-public”, uppercase names “public”, so you could rename the perform to one thing with an uppercase letter in the beginning.

You additionally need to use one other bundle for that, which you’ll then import out of your major.

Throughout the identical bundle it doesn’t matter.

Hello @mj4code, the file handler_readiness.go resides in the identical listing as major.go, therefore it should additionally belong to bundle major. You don’t want to import capabilities from one other file of the identical bundle. They’re accessible to all different information of that bundle.

If you wish to make handler_readiness.go a separate bundle, transfer it to a subdirectory and make sure the capabilities are exported (as @NobbZ has described).

I feel you could use: go run .
as an alternative of go run major.go which can solely compile one file and never all go information within the listing.

The go devs even counsel you need to use go construct && go-project.exe to run your code as an alternative of go run in improvement.

1 Like

It isn’t the identical bundle. And whether it is, then that ought to actually be modified.

I’ve had nothing however bother utilizing a major bundle spanning a number of information.

@falco467 Yeah that labored. Thanks alot !

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments