1
0
mirror of https://github.com/golang/go synced 2024-11-05 22:36:10 -07:00
Commit Graph

191 Commits

Author SHA1 Message Date
Felix Cornelius
964fac3ee7 doc: update Effective Go with 1.14 language changes
Fixes #37560

Change-Id: Iccb8e53254c45d203c1b42ea9b4d8509b93dd7a9
GitHub-Last-Rev: 5972b67e5d
GitHub-Pull-Request: golang/go#37563
Reviewed-on: https://go-review.googlesource.com/c/go/+/221429
Reviewed-by: Rob Pike <r@golang.org>
2020-02-28 20:15:38 +00:00
Rob Pike
bb0a8fd38f doc: reword to avoid the confusing term 'anew'
Fixes #34415

Change-Id: I8eaa7606ae01e569a076cf7f3c28dbec2a153001
Reviewed-on: https://go-review.googlesource.com/c/go/+/196578
Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
2019-09-20 08:06:51 +00:00
Alberto Donizetti
2d1a1e0a2a doc: fix Block interface parameters order
The Effective Go document references the crypto/cipher Block
interface, but the parameters' names are swapped. This change
alignes them to the crypto definition, to avoid confusion.

Fixes #33432

Change-Id: I8b9aac4dc6af3eec968bbc8f3ee5366b99016fcc
Reviewed-on: https://go-review.googlesource.com/c/go/+/188797
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2019-08-02 17:51:34 +00:00
Rob Pike
fd19bc64de doc: add missing paragraph break in Effective Go
A recent edit broke the flow; add a paragraph break when the subject
switches from maps to structs.

No changes in wording.

Change-Id: I5df88ec36b9d81931cfdbc684424440d01ac06d1
Reviewed-on: https://go-review.googlesource.com/c/go/+/165917
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2019-03-07 04:46:03 +00:00
Rob Pike
c7408a8775 doc: sort map output in Effective Go
And explain that it does this. A minor change probably worth mentioning,
although (#28782) I'd still like to freeze this document against any substantial
changes.

Fix #30568.

Change-Id: I74c56744871cfaf00dc52a9b480ca61d3ed19a6b
Reviewed-on: https://go-review.googlesource.com/c/go/+/165597
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2019-03-06 03:51:21 +00:00
Gabriel Aszalos
73fb3c38a6 doc: remove incorrect space in %T and %v output examples
Change-Id: I321890237f703b945711e59c15233ccf59c4f190
Reviewed-on: https://go-review.googlesource.com/c/156477
Run-TryBot: Gabriel Aszalos <gabriel.aszalos@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2019-01-07 14:13:33 +00:00
Rob Pike
cf20540880 doc: improve the interface example in Effective Go
The String method is n-squared and overwrites its receiver.
Fix both issues, with only a slight loss of clarity.

Fixes #28773

Change-Id: I588f69d4cbd72931b28b984671512834473bd466
Reviewed-on: https://go-review.googlesource.com/c/151217
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-11-26 05:08:25 +00:00
Agniva De Sarker
3553eca27c doc: replace command line usages of godoc with go doc
Effective Go and the FAQ still had some instances which showed the command line
usage of godoc. Changed them to use go doc.

Updates #25443

Change-Id: If550963322034e6848bc466f79e968e7220e4a88
Reviewed-on: https://go-review.googlesource.com/c/145222
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-10-31 20:08:50 +00:00
Genevieve Luyt
b917bdd3ba doc: use the new log functions
The log interface was changed in https://golang.org/cl/2419042.

Change-Id: I3eaddd8a5cfcae961db16555fb1b0ce6770b6334
Reviewed-on: https://go-review.googlesource.com/c/143777
Reviewed-by: Rob Pike <r@golang.org>
2018-10-22 19:57:05 +00:00
Rob Pike
7c2718b12a doc: tweak example in Effective Go
A prior attempt at addressing the issue got bogged down in an
endless conversation around the subtleties of Read semantics.
Let's not go there.

Instead, we put the issue to bed, perhaps not in perfect comfort
but well enough, by moving a line of the example so that even
if there is a "benign" error as the issue suggests, the loop
terminates with n and err correctly set.

Fixes #27818

Change-Id: I4a32d56c9e782f17578565d90b22ce531e3d8667
Reviewed-on: https://go-review.googlesource.com/c/143677
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2018-10-22 05:44:46 +00:00
Alberto Donizetti
a3bafcf8cc doc: make chart.apis.google.com link not clickable
The example in the 'A web server' section of the effective Go document
uses Google's image charts API (at chart.apis.google.com).

The service is now deprecated (see developers.google.com/chart/image),
and visiting http://chart.apis.google.com gives a 404. The endpoint is
still active, so the Go code in the example still works, but there's
no point in making the link clickable by the user if the page returns
a 404.

Change the element to `<code>`.

Change-Id: Ie67f4723cfa636e3dc1460507055b6bbb2b0970c
Reviewed-on: https://go-review.googlesource.com/109576
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-04-26 18:26:06 +00:00
Tom Levy
8a092b74fc doc: fix typo in Effective Go: s/ReaderWriter/ReadWriter/
Change-Id: I3bfe1b11265f0def4701faf2cfc1ad10a666a473
Reviewed-on: https://go-review.googlesource.com/79596
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2017-11-23 04:07:39 +00:00
Gabriel Aszalos
c40579ac75 doc: simplify Append example in "Effective Go"
Change-Id: I011486993b167e65c69da1c8390bbcc625ca58c3
Reviewed-on: https://go-review.googlesource.com/64331
Reviewed-by: Rob Pike <r@golang.org>
2017-09-19 00:48:10 +00:00
Andrii Soldatenko
53d24f76fb doc: Fixed missing dot in effective_go.html
First sentence of https://golang.org/doc/effective_go.html#maps dot is missing.

Change-Id: Ic93b407945a6ad24a73ae9f7b6076ac9619871db
Reviewed-on: https://go-review.googlesource.com/61020
Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
2017-09-03 21:23:06 +00:00
James Neve
868bb5d2f2 doc: escape some HTML in Effective Go code examples
Change-Id: I4204e268c7220a50ceb270432067850ec2b5af80
Reviewed-on: https://go-review.googlesource.com/41230
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2017-04-20 16:29:19 +00:00
Kevin Burke
7603aa7907 doc: use appropriate type to describe return value
Fixes #19223.

Change-Id: I4cc8e81559a1313e1477ee36902e1b653155a888
Reviewed-on: https://go-review.googlesource.com/37374
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
2017-02-21 22:15:26 +00:00
Rob Pike
cec84f7309 doc/effectivego: reword confusing sentence
For some reason git won't let me write

	doc/effective_go.html: reword confusing sentence

or even

	doc/effective_go: reword confusing sentence

as the subject line for this CL, but that's not important. The
actual CL just rewrites one sentence and adds an option to grep in
the associated example.

Fixes #15875

Change-Id: Iee159ea751caf4b73eacf3dfc86e29032646373f
Reviewed-on: https://go-review.googlesource.com/32110
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2016-10-26 16:09:54 +00:00
Vitor De Mario
e888b81a11 doc: change variable name in Effective Go
Effective Go has references to a function call f(c, req) made by ServeHTTP mixed with f(w,
req). c is dropped in favor of w to maintain consistency

Fixes #17128

Change-Id: I6746fd115ed5a58971fd24e54024d29d18ead1fa
Reviewed-on: https://go-review.googlesource.com/29311
Reviewed-by: Rob Pike <r@golang.org>
2016-09-16 01:10:51 +00:00
Bryan C. Mills
2fcb25e07b doc/effective_go: clarify advice on returning interfaces
New Gophers sometimes misconstrue the advice in the "Generality" section
as "export interfaces instead of implementations" and add needless
interfaces to their code as a result.  Down the road, they end up
needing to add methods and either break existing callers or have to
resort to unpleasant hacks (e.g. using "magic method" type-switches).

Weaken the first paragraph of this section to only advise leaving types
unexported when they will never need additional methods.

Change-Id: I32a1ae44012b5896faf167c02e192398a4dfc0b8
Reviewed-on: https://go-review.googlesource.com/24892
Reviewed-by: Rob Pike <r@golang.org>
Reviewed-by: Andrew Gerrand <adg@golang.org>
2016-07-13 16:19:07 +00:00
Ian Lance Taylor
c6a5b3602a doc/effective_go: clarify backward function reference
Fixes #14656.

Change-Id: I37a9aa51705ae18bd034f2cc6dbf06a55f969197
Reviewed-on: https://go-review.googlesource.com/23202
Reviewed-by: Rob Pike <r@golang.org>
2016-05-18 13:17:34 +00:00
Brad Fitzpatrick
351c15f1ce all: remove public named return values when useless
Named returned values should only be used on public funcs and methods
when it contributes to the documentation.

Named return values should not be used if they're only saving the
programmer a few lines of code inside the body of the function,
especially if that means there's stutter in the documentation or it
was only there so the programmer could use a naked return
statement. (Naked returns should not be used except in very small
functions)

This change is a manual audit & cleanup of public func signatures.

Signatures were not changed if:

* the func was private (wouldn't be in public godoc)
* the documentation referenced it
* the named return value was an interesting name. (i.e. it wasn't
  simply stutter, repeating the name of the type)

There should be no changes in behavior. (At least: none intended)

Change-Id: I3472ef49619678fe786e5e0994bdf2d9de76d109
Reviewed-on: https://go-review.googlesource.com/20024
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Andrew Gerrand <adg@golang.org>
2016-02-29 03:31:19 +00:00
Brad Fitzpatrick
aa5118b129 doc: remove mention of default GOMAXPROCS(1) in Effective Go
Fixes #11781

Change-Id: Idc46a6a4fb5bf1c4d394eadf2d860d7ef75c8ccf
Reviewed-on: https://go-review.googlesource.com/12390
Reviewed-by: Rob Pike <r@golang.org>
2015-07-21 02:45:44 +00:00
Brad Fitzpatrick
26f12beb5d doc: add a missing space in func signature
Fixes #11383

Change-Id: I7ef0bb8b535ef513afdfcda19317ae4ff21f7166
Reviewed-on: https://go-review.googlesource.com/11490
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
2015-06-25 05:34:14 +00:00
Brandon Gilmore
b9bd57e715 doc/effective_go: fix grammatical error
Change-Id: Ib52854169f3dd18f54d3ae9263c897d3f45ea869
Reviewed-on: https://go-review.googlesource.com/10982
Reviewed-by: Andrew Gerrand <adg@golang.org>
2015-06-12 20:29:22 +00:00
Brett Cannon
3a3773c8cb doc/effective_go: make function signature match function body
In the Slices section of Effective Go, the os package's File.Read
function is used as an example. Unfortunately the function signature
does not match the function's code in the example, nor the os package's
documentation. This change updates the function signature to match
the os package and the pre-existing function code.

Change-Id: Iae9f30c898d3a1ff8d47558ca104dfb3ff07112c
Reviewed-on: https://go-review.googlesource.com/9845
Reviewed-by: Rob Pike <r@golang.org>
2015-05-08 17:01:24 +00:00
Michael Vetter
0e1da61cfb doc/effective_go.html: add missing newline
When printing the type of the function there was no newline printed in
case of unexpected type.

Change-Id: I5946413f0864f712a1b955f488b436793018e0e0
Reviewed-on: https://go-review.googlesource.com/7480
Reviewed-by: Minux Ma <minux@golang.org>
2015-03-12 16:31:23 +00:00
Russ Cox
220a6de47e build: adjustments for move from src/pkg to src
This CL adjusts code referring to src/pkg to refer to src.

Immediately after submitting this CL, I will submit
a change doing 'hg mv src/pkg/* src'.
That change will be too large to review with Rietveld
but will contain only the 'hg mv'.

This CL will break the build.
The followup 'hg mv' will fix it.

For more about the move, see golang.org/s/go14nopkg.

LGTM=r
R=r
CC=golang-codereviews
https://golang.org/cl/134570043
2014-09-08 00:06:45 -04:00
Andrew Gerrand
43ad89d627 doc: drop scheme from links that are known to support HTTPS
golang.org now serves HTTPS with a valid cert, so it's reasonable
that users should click through to the HTTPS versions of *.golang.org
and other known sites.

LGTM=bradfitz
R=golang-codereviews, bradfitz
CC=golang-codereviews
https://golang.org/cl/112650043
2014-07-25 10:28:39 +10:00
Rob Pike
1476686cdb doc/effective_go.html: a little more about errors
Make it a little clearer how they are used, in particular that
it is not enough just to return a nil pointer on error, but also
to return an error value explaining the problem.

Fixes #1963.

LGTM=bradfitz
R=golang-codereviews, bradfitz
CC=golang-codereviews
https://golang.org/cl/97360045
2014-05-14 13:46:58 -07:00
Dmitriy Vyukov
2e1ddeb136 doc: replace absolute links to golang.org with relative links
Currently tip.golang.org leads to golang.org and
local godoc also leads to golang.org (when you don't have internet connectivity).

LGTM=crawshaw
R=golang-codereviews, crawshaw
CC=golang-codereviews
https://golang.org/cl/100200043
2014-05-07 18:49:13 +04:00
Shenghou Ma
f8f34c330c doc/effective_go: mention that b.Write is a shorthand for (&b).Write when b is addressable.
The rewrite is due to Rob.

LGTM=r, bradfitz, josharian
R=golang-codereviews, bradfitz, r, josharian
CC=golang-codereviews
https://golang.org/cl/87410043
2014-04-17 01:40:04 -04:00
Russ Cox
132e816734 doc: allow buffered channel as semaphore without initialization
This rule not existing has been the source of many discussions
on golang-dev and on issues. We have stated publicly that it is
true, but we have never written it down. Write it down.

Fixes #6242.

LGTM=r, dan.kortschak, iant, dvyukov
R=golang-codereviews, r, dominik.honnef, dvyukov, dan.kortschak, iant, 0xjnml
CC=golang-codereviews
https://golang.org/cl/75130045
2014-03-24 19:11:21 -04:00
Rob Pike
0c8415699e doc/effective_go.html: fix typo
Prose referred to 'b', code used 'buf'.
Fixes #7601.

LGTM=dominik.honnef
R=golang-codereviews, dominik.honnef
CC=golang-codereviews
https://golang.org/cl/78470043
2014-03-21 08:37:27 +11:00
Rob Pike
592415d682 effective_go: move 'Type switch' section into 'Control structures' section.
Needs to be an h3, not an h2.
Thanks to Mingjie Xing for pointing it out.

LGTM=dsymonds
R=golang-codereviews, dsymonds
CC=golang-codereviews
https://golang.org/cl/55980046
2014-01-23 16:26:42 -08:00
David Symonds
1e67453d93 doc: replace "private" with "unexported" in Effective Go.
R=r
CC=golang-codereviews
https://golang.org/cl/53720043
2014-01-17 09:06:39 -08:00
Josh Bleecher Snyder
de4ca13eac doc: fix typo in Effective Go
R=adg, bradfitz
CC=golang-codereviews
https://golang.org/cl/44430043
2013-12-20 09:59:51 -08:00
Oling Cat
b349477eab doc/effective_go.html: close some tags.
R=golang-dev, minux.ma
CC=golang-dev
https://golang.org/cl/37700043
2013-12-11 09:49:28 +11:00
Shenghou Ma
244014e402 doc/effective_go.html: fix code example
Fixes #6595.

R=golang-dev, adg
CC=golang-dev
https://golang.org/cl/14425062
2013-10-15 21:30:49 -04:00
Rob Pike
7f168f9ccf doc/effective_go.html: fix unescaped less-than character
Why doesn't tidy complain about these?
Found by manlio.perillo.
Fixes #6571

R=golang-dev, adg
CC=golang-dev
https://golang.org/cl/14608044
2013-10-11 16:39:40 -07:00
Rob Pike
beca0e124d doc/effective_go.html: fix a couple of cosmetic issues
At the moment, godoc expands the example in the link, but in
the past it has not. Add a waffle word to allow either possibility.
Also change the order of cases in the switch in Compare to
be consistent with the other switch in the function.

R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/14439055
2013-10-10 17:26:03 -07:00
Andrew Gerrand
48ba6fe553 doc: move spec and memory model back to /ref/
R=golang-dev, r
CC=golang-dev
https://golang.org/cl/14364043
2013-10-04 09:45:06 +10:00
Rob Pike
d38ed2a9f2 doc/effective_go: fix server example that shares var between goroutines
Use it as a teaching example about how to solve this problem.

Fixes #6501

R=golang-dev, adg, rsc
CC=golang-dev
https://golang.org/cl/14250043
2013-10-02 11:35:25 -07:00
Andrew Gerrand
1f7c8a9aed doc: update links to spec and memory model
Fixes #6488.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/14004043
2013-09-27 09:46:36 +10:00
Rob Pike
2a5dcfafec effective_go: add a discussion of labeled break and continue
Fixes #5725.

R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/13705044
2013-09-17 07:41:45 +10:00
Rob Pike
38a77ff03f doc/effective_go.html: remove spurious word
Fixes #6003.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/12387045
2013-08-05 11:24:27 +10:00
Rémy Oudompheng
d26d5e6403 effective_go.html: make snippets look formatted.
R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/11991043
2013-07-29 00:57:19 +02:00
Dave Cheney
deee03f17e doc/effective_go: stamp out stray GOROOT reference
Replaced with something more appropriate.

R=adg, r, minux.ma
CC=golang-dev
https://golang.org/cl/11421043
2013-07-17 18:48:55 +10:00
Brian G. Merrell
20c524c5e2 effective_go.html: Fix two links
This fixes two intra-page "type assertion" links that were broken in
different ways.

R=golang-dev, dsymonds
CC=golang-dev
https://golang.org/cl/9797043
2013-05-27 11:00:12 +10:00
Rob Pike
2f326da27e effective_go.html: be more accepting in the guidelines for interface names
Fixes #5421.

R=golang-dev, bradfitz, adg
CC=golang-dev
https://golang.org/cl/9274043
2013-05-07 11:41:36 -07:00
Andrew Gerrand
48c4a87a94 doc: fix formatting in effective go code snippet
Fixes #5403.

R=golang-dev, minux.ma
CC=golang-dev
https://golang.org/cl/9100046
2013-05-03 15:24:05 -04:00