Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

This documentation is great, but one thing I tend to miss with examples like these is how to structure a project, deal with packages, etc.


GitHub is your friend here.

Here is a search for Go repositories with > 100 stars.[1] Every project will look different (the really big ones might be more complex then you need) but as you get deeper into the results you can find some great stuff.

[1]: https://github.com/search?l=go&q=stars%3A%3E100&s=stars&type...


That's a great idea, I hadn't thought of that.


"How to Write Go Code" shows you this, and is a good read: http://golang.org/doc/code.html


Thank you for your reference. I wish I could save it somewhere when I have time to go through it.

- Eggs should not be washed.


Agreed, the community does seem pretty loose on project structure--which is interesting since the language takes such strong stances on code structure.

Since your folder structure is also your package structure, with rmux[1] I tried to separate the project into dependencies, and use a package for each one. I like to also limit files to one class--but if you read through the default package files, the creators seems to go both ways.

One interesting thing that isn't mentioned often is how to handle the equivalent of #ifdef, through +build flags. This isn't the best solution, since all functions and their arguments are evaluated (even empty functions), but it does allow for the use of constants to wrap around cpu-wasteful debug-only areas/

[1]: https://github.com/forcedotcom/rmux




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

Search: