go lang best practices and git repo structure for newbies

141 views
Skip to first unread message

vteja...@gmail.com

unread,
Apr 23, 2018, 1:39:10 PM4/23/18
to golang-nuts
Hello,

I was quite new to go lang. It would be good if anyone can help with best practices and practical git repo structure example for getting inspiration to kick start.

Thanks,
Teja

matthe...@gmail.com

unread,
Apr 23, 2018, 2:36:00 PM4/23/18
to golang-nuts
Hi Teja,

I found Effective Go to be generally helpful: https://golang.org/doc/effective_go.html

Here’s my best example: https://github.com/pciet/wichess

My golang-nuts code review points:

- don’t overuse interface (consider closures and function types/fields)
- don’t overuse packages, make more files in the same package first
- focus on the godoc presentation
- consider struct embedding
- slices are more efficient and readable than maps for some kinds of unordered sets
- a struct of pointers is similar to a pointer to a struct
- profile before making any choice away from easy code

For newbies:

- Writing computer programs with if, for, types, functions, and libraries is an art that many people might like. What Go brings is less wading through mud than C, Java, and scripting languages.
- Pointers are a hard part of Go and you should learn them well enough to not have any pointer questions. Map and interface vars are pointers, and a slice has a pointer to the array (a slice is a struct).
- stackoverflow.com, golang.org, golang-nuts, and Dave Cheney's blog are good resources among others.

Matt

vteja...@gmail.com

unread,
Apr 24, 2018, 1:26:49 AM4/24/18
to golang-nuts
Thank you Matt, I will start reading as you mentioned.

BR,
Teja

Louki Sumirniy

unread,
Apr 24, 2018, 2:08:53 AM4/24/18
to golang-nuts
This git repository shows an example of all the common conventions for build layout https://github.com/golang-standards/project-layout
Reply all
Reply to author
Forward
0 new messages