Could anyone please explain how packages work


(Евгений Фарсалов) #1

Hello dear pros.
Ive cloned the repo https://github.com/sahilm/shouter and tryed to run in GoLand 2018.3.3

it has 3 go files + test. One of the files is in separate directory - main.go. Package name is shouter. It kept saying it couldnt find the package, and lots of other errors after my different action in effort to fix it.

I did everything I could find on the net but the only thing helped me was to rename package to main and removed git link from import. Oh, and I’ve put all files into the same folder.

What should have I done to make it work? Thanks in advance.


(Norbert Melzer) #2

Go is very opinionated about how sources needs to be organized.

Simply put, it strictly has to be $GOPATH/src/$package_name, unless you use go modules. Which that project does not.