From 58837a8186c28f231f08cdf2cdecf35b2b3a07db Mon Sep 17 00:00:00 2001 From: Brian Picciano Date: Mon, 26 Mar 2018 10:54:01 +0000 Subject: [PATCH] README: add styleguide section --- README.md | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/README.md b/README.md index b0232da..91c66f9 100644 --- a/README.md +++ b/README.md @@ -12,3 +12,24 @@ Other third-party packages which integrate into these: package has a specific error it might return and which might be checked for a function to perform that equality check will be supplied as part of the package. + +## Styleguide + +Here are general guidelines I use when making decisions about how code in this +repo should be written. Most of the guidelines I have come up with myself have +to do with package design, since packages are the only thing which have any +rigidity and therefore need any rigid rules. + +Everything here are guidelines, not actual rules. + +* `gofmt -s` + +* https://golang.org/doc/effective_go.html + +* https://github.com/golang/go/wiki/CodeReviewComments + +* When deciding if a package should initialize a struct as a value or pointer, a + good rule is: If it's used as an immutable value it should be a value, + otherwise it's a pointer. Even if the immutable value implementation has + internal caching, locks, etc..., that can be hidden as pointers inside the + struct, but the struct itself can remain a value type.