# Effective Go, a Digest
## Communicating With Fellow Programmers Through The Program
The unqiue/useful thing we're saying to each other is the meaning/intent of the code — why are we doing this at all?
Sources of meaning/intention/raison d'etre:
- from the word(s) of the variable or function, itself.
- from justaposition with _other_ variables/functions.
- from its membership on a type (~concept)
- from its membership in a package (~bounded context)
## Names
re: https://go.dev/doc/effective_go#names
- "A helpful doc comment can often be more valuable than an extra long name."
- the identifier itself should convey the essential intention, not necessarily the whole idea.
-
### Spelling
- single characters:
- for method receivers (because the object is ubiquious/familiar within the method)
- where: for all "usage": distance(from: declaration, to: usage) <= 3
- e.g. for loop declaration
- e.g. return value of a function that also returns and error
- single word nouns:
- where:
- scope(declaration) = within a function body or smaller
- for at least one "usage": distance(from: declaration, to: usage) > 3
- where:
- the role of the variable _is_ as generic as the simple noun
- e.g. "file" when truly holds, generically, a file
- the role of the variable is the primary of a set of nouns, others of which are qualified
- e.g. "schema" along with "childLibSchema"
- qualified nouns:
- where:
- there is more than one of a given noun in play
-
### Word Choice
## Language Details
There are X flavors of `switch` statements:
1. basic switch — a value matched against individual cases (each of which can be variable)
2. type switch — switch on `.(type)`
3. "condition-less" switch — by default, the condition of `switch` is true. using the `;`, one can make an assignment and then switch from the given cases.
`switch` nuances:
1. cases are evaluated top-to-bottom, left-to-right.
1. case list — using `,` to combine cases
2. `fallthrough` continues execution to next case _without_ evaluating that case's condition.
### What's the point of new()?
From what I can tell, `new()` has exactly one distinguishing and sufficiently useful case to justify its existence:
```go=
return new(int)
```
is sufficiently more compact than:
```go=
var i int
return &i
```