@@ -195,8 +195,8 @@ const (
195195
196196Words in names that are initialisms or acronyms (e.g., ` URL ` and ` NATO ` ) should
197197have the same case. ` URL ` should appear as ` URL ` or ` url ` (as in ` urlPony ` , or
198- ` URLPony ` ), never as ` Url ` . This also applies to ` ID ` when it is short for
199- "identifier"; write ` appID ` instead of ` appId ` .
198+ ` URLPony ` ), never as ` Url ` . As a general rule, identifiers (e.g., ` ID ` and ` DB ` )
199+ should also be capitalized similar to their usage in English prose .
200200
201201* In names with multiple initialisms (e.g. ` XMLAPI ` because it contains ` XML `
202202 and ` API ` ), each letter within a given initialism should have the same case,
@@ -211,7 +211,7 @@ have the same case. `URL` should appear as `URL` or `url` (as in `urlPony`, or
211211
212212<!-- Keep this table narrow. If it must grow wider, replace with a list. -->
213213
214- Initialism(s) | Scope | Correct | Incorrect
214+ English Usage | Scope | Correct | Incorrect
215215------------- | ---------- | -------- | --------------------------------------
216216XML API | Exported | ` XMLAPI ` | ` XmlApi ` , ` XMLApi ` , ` XmlAPI ` , ` XMLapi `
217217XML API | Unexported | ` xmlAPI ` | ` xmlapi ` , ` xmlApi `
@@ -221,6 +221,11 @@ gRPC | Exported | `GRPC` | `Grpc`
221221gRPC | Unexported | ` gRPC ` | ` grpc `
222222DDoS | Exported | ` DDoS ` | ` DDOS ` , ` Ddos `
223223DDoS | Unexported | ` ddos ` | ` dDoS ` , ` dDOS `
224+ ID | Exported | ` ID ` | ` Id `
225+ ID | Unexported | ` id ` | ` iD `
226+ DB | Exported | ` DB ` | ` Db `
227+ DB | Unexported | ` db ` | ` dB `
228+ Txn | Exported | ` Txn ` | ` TXN `
224229
225230<!-- #include file="/go/g3doc/style/includes/special-name-exception.md"-->
226231
@@ -1779,7 +1784,7 @@ canvas.RenderCube(cube,
17791784` ` `
17801785
17811786Note that the lines in the above example are not wrapped at a specific column
1782- boundary but are grouped based on co-ordinate triples.
1787+ boundary but are grouped based on coordinate triples.
17831788
17841789Long string literals within functions should not be broken for the sake of line
17851790length. For functions that include such strings, a line break can be added after
@@ -2043,6 +2048,8 @@ For errors that indicate "impossible" conditions, namely bugs that should always
20432048be caught during code review and/or testing, a function may reasonably return an
20442049error or call [` log.Fatal ` ].
20452050
2051+ Also see [when panic is acceptable](best-practices.md#when-to-panic).
2052+
20462053**Note:** ` log.Fatalf ` is not the standard library log. See [#logging].
20472054
20482055[Effective Go section on errors]: http://golang.org/doc/effective_go.html#errors
@@ -2176,12 +2183,18 @@ clear. It is conventionally managed with a `context.Context`:
21762183` ` ` go
21772184// Good:
21782185func (w *Worker) Run (ctx context.Context ) error {
2186+ var wg sync.WaitGroup
21792187 // ...
21802188 for item := range w.q {
21812189 // process returns at latest when the context is cancelled.
2182- go process (ctx, item)
2190+ wg.Add (1 )
2191+ go func () {
2192+ defer wg.Done ()
2193+ process (ctx, item)
2194+ }()
21832195 }
21842196 // ...
2197+ wg.Wait () // Prevent spawned goroutines from outliving this function.
21852198}
21862199` ` `
21872200
@@ -2222,12 +2235,14 @@ See also:
22222235* Rethinking Classical Concurrency Patterns: [slides][rethinking-slides],
22232236 [video][rethinking-video]
22242237* [When Go programs end]
2238+ * [Documentation Conventions: Contexts]
22252239
22262240[synchronous functions]: #synchronous-functions
22272241[cheney-stop]: https://dave.cheney.net/2016/12/22/never-start-a-goroutine-without-knowing-how-it-will-stop
22282242[rethinking-slides]: https://drive.google.com/file/d/1nPdvhB0PutEJzdCq5ms6UI58dp50fcAN/view
22292243[rethinking-video]: https://www.youtube.com/watch?v=5zXAHh5tJqQ
22302244[When Go programs end]: https://changelog.com/gotime/165
2245+ [Documentation Conventions: Contexts]: best-practices.md#documentation-conventions-contexts
22312246
22322247<a id="interfaces"></a>
22332248
@@ -2737,7 +2752,7 @@ formatting to do.
27372752See also:
27382753
27392754* Best practices on [logging errors](best-practices#error-logging) and
2740- [custom verbosily levels](best-practices#vlog)
2755+ [custom verbosity levels](best-practices#vlog)
27412756* When and how to use the log package to
27422757 [stop the program](best-practices#checks-and-panics)
27432758
0 commit comments