Hacker News new | past | comments | ask | show | jobs | submit login

Code organization question: is this a common convention in Go, to nest the main package in a subdirectory and put all of the 'modules' in different files but with the same package name?

(I'm more used to the Clojure namespace/filesystem symmetry, so this is somewhat new to me. I like the more shallow project tree but it's not immediately apparent where things are defined.)




In a package, main or otherwise, files are purely for programmer convenience. They define import scope but are otherwise transparent to the toolchain.


You have to have your main() in package "main" and all your files in one directory have to be in the same package. So when you want a main() and your logic in a "real" package, your have to seperate them.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: