aboutsummaryrefslogtreecommitdiff
path: root/src/bytes/example_test.go
AgeCommit message (Collapse)Author
2023-01-20bytes,strings: add some examplesfangguizhen
Change-Id: Ic93ad59119f3549c0f13c4f366f71e9d01b88c47 GitHub-Last-Rev: afb518047288976f440d3fe0d65923c1905a9b26 GitHub-Pull-Request: golang/go#57907 Reviewed-on: https://go-review.googlesource.com/c/go/+/462283 TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Ian Lance Taylor <iant@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Reviewed-by: Cherry Mui <cherryyz@google.com> Run-TryBot: Ian Lance Taylor <iant@golang.org> Auto-Submit: Ian Lance Taylor <iant@google.com>
2021-11-05bytes: add example with (*Buffer).Cap, (*Buffer).Read, (*Buffer).ReadBytejiahua wang
Change-Id: Ieb107fdfccde9f054491f667a384b16f7af71dea Reviewed-on: https://go-review.googlesource.com/c/go/+/355289 Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org> Trust: Cherry Mui <cherryyz@google.com>
2021-10-06bytes, strings: add CutRuss Cox
Using Cut is a clearer way to write the vast majority (>70%) of existing code that calls Index, IndexByte, IndexRune, and SplitN. There is more discussion on https://golang.org/issue/46336. Fixes #46336. Change-Id: Ia418ed7c3706c65bf61e1b2c5baf534cb783e4d3 Reviewed-on: https://go-review.googlesource.com/c/go/+/351710 Trust: Russ Cox <rsc@golang.org> Run-TryBot: Russ Cox <rsc@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
2021-09-27bytes: add example for (*Buffer).Nextjiahua wang
Change-Id: Ic0a97fd7bb89865448e436e5c092415a29d8badf Reviewed-on: https://go-review.googlesource.com/c/go/+/352009 Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org> Trust: David Chase <drchase@google.com>
2020-11-11bytes: add example for (*Buffer).BytesFederico Guerinoni
Change-Id: I49ac604530fff7928fa15de07563418b104da5e4 Reviewed-on: https://go-review.googlesource.com/c/go/+/268260 Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org> Trust: Giovanni Bajo <rasky@develer.com>
2019-03-01bytes: add examples for ToTitleSpecial, ToUpperSpecial and ToLowerSpecialKetan Parmar
Change-Id: If700a150492181f68e23e90ef829ff9eaf7ca7b5 Reviewed-on: https://go-review.googlesource.com/c/161737 Run-TryBot: Andrew Bonventre <andybons@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Andrew Bonventre <andybons@golang.org>
2018-12-13bytes: add ReplaceAll exampledupoxy
Change-Id: I36cc0b68a5a47ac78982b05118c58723c9c6648c GitHub-Last-Rev: 0704d9569407d8b84d1ddcf845b759f7daa91ec1 GitHub-Pull-Request: golang/go#29203 Reviewed-on: https://go-review.googlesource.com/c/153842 Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
2018-08-30bytes: add example for Buffer.LenErin Masatsugu
Change-Id: Ide50aba940727a7b32cd33dea5315050f1a34717 Reviewed-on: https://go-review.googlesource.com/132237 Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
2017-11-15bytes, strings: restore O(1) behavior of IndexAny(s, "") and LastIndexAny(s, "")Russ Cox
CL 65851 (bytes) and CL 65910 (strings) “improve[d] readability” by removing the special case that bypassed the whole function body when chars == "". In doing so, yes, the function was unindented a level, which is nice, but the runtime of that case went from O(1) to O(n) where n = len(s). I don't know if anyone's code depends on the O(1) behavior in this case, but quite possibly someone's does. This CL adds the special case back, with a comment to prevent future deletions, and without reindenting each function body in full. Change-Id: I5aba33922b304dd1b8657e6d51d6c937a7f95c81 Reviewed-on: https://go-review.googlesource.com/78112 Run-TryBot: Russ Cox <rsc@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2017-11-15bytes: make ExampleTrimLeft and ExampleTrimRight matchRuss Cox
ExampleTrimLeft was inexplicably complex. Change-Id: I13ca81bdeba728bdd632acf82e3a1101d29b9f39 Reviewed-on: https://go-review.googlesource.com/78111 Run-TryBot: Russ Cox <rsc@golang.org> Reviewed-by: Joe Tsai <thebrokentoaster@gmail.com>
2017-11-15bytes: change ExampleReader_Len to use a non-ASCII stringRuss Cox
This should help make clear that Len is not counting runes. Also delete empty string, which doesn't add much. Change-Id: I1602352df1897fef6e855e9db0bababb8ab788ca Reviewed-on: https://go-review.googlesource.com/78110 Run-TryBot: Russ Cox <rsc@golang.org> Reviewed-by: Joe Tsai <thebrokentoaster@gmail.com>
2017-10-16bytes: add examples of Equal and IndexByteJavier Segura
Change-Id: Ibf3179d0903eb443c89b6d886802c36f8d199898 Reviewed-on: https://go-review.googlesource.com/70933 Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com> Run-TryBot: Emmanuel Odeke <emm.odeke@gmail.com> TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-09-17bytes: add example for Len function of ReaderAndrzej Żeżel
Change-Id: If7ecdc57f190f647bfc673bde8e66b4ef12aa906 Reviewed-on: https://go-review.googlesource.com/64190 Reviewed-by: Ian Lance Taylor <iant@golang.org> Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-08-25bytes: Add missing examples to functionsBorja Clemente
Fixes #21570 Change-Id: Ia0734929a04fbce8fdd5fbcb1b7baff9a8bbe39e Reviewed-on: https://go-review.googlesource.com/58030 Reviewed-by: Robert Griesemer <gri@golang.org> Reviewed-by: Joe Tsai <thebrokentoaster@gmail.com> Run-TryBot: Robert Griesemer <gri@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-08-22bytes: add examples for TrimLeft and TrimRightMichael Brandenburg
Change-Id: Ib6d94f185dd43568cf97ef267dd51a09f43a402f Reviewed-on: https://go-review.googlesource.com/51391 Reviewed-by: Joe Tsai <thebrokentoaster@gmail.com> Run-TryBot: Joe Tsai <thebrokentoaster@gmail.com> TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-07-16bytes: add example for (*Buffer).GrowBrian Downs
Change-Id: I04849883dd2e1f6d083e9f57d2a8c1bd7d258953 Reviewed-on: https://go-review.googlesource.com/48878 Run-TryBot: Bryan Mills <bcmills@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Bryan Mills <bcmills@google.com>
2016-08-16bytes: add examplesCarlos C
`bytes` and `strings` are pretty similar to each other, this commit brings `strings` examples to its counter-part. Partially addresses #16360 Change-Id: I551320eaa78be9df69012035f1c3333f500e04c9 Reviewed-on: https://go-review.googlesource.com/25062 Reviewed-by: Andrew Gerrand <adg@golang.org> Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
2014-09-08build: move package sources from src/pkg to srcRuss Cox
Preparation was in CL 134570043. This CL contains only the effect of 'hg mv src/pkg/* src'. For more about the move, see golang.org/s/go14nopkg.