Hello,
I am facing issue while importing function. I have the directory structure as mentioned in the screenshot.
I want to import function “handlerReadiness” from handler_readiness.go into main.go. But when I run the main.go file, it says “undefined handlerReadiness”.
Although when I hover over handlerReadiness, I can see the function in defined and can reach to it’s definition by doing command+click.
Hi @mj4code, the file handler_readiness.go resides in the same directory as main.go, hence it must also belong to package main. You do not need to import functions from another file of the same package. They are available to all other files of that package.
If you want to make handler_readiness.go a separate package, move it to a subdirectory and ensure the functions are exported (as @NobbZ has described).