I faced a problem when for some reason I can not place function in package and then use that package. Look at the pic below:
Here is a main.go file which is in package main and I moved function randomInt into package cityutil and try to use it in the main.go file. So IDE suggest to me to import that newly created package - I did it. Look at it:
Then I press save file and those import “citiestemp/cityutil” disapeared for some reason. So I mention what is the reason of that behaviour? Why I cat not import it that way?
@cinematik from my understanding; the functions and methods declared in main.go can not be exported to packages.
In order to use a function/method across your application you would have to create a package that exports those functions/methods and then import them to each script.