summaryrefslogtreecommitdiff
path: root/src/fmt/example_test.go
Commit message (Collapse)AuthorAgeFilesLines
* fmt: fix spelling mistake in exampleRob Pike2019-03-251-5/+5
| | | | | | | | | | Mea culpa. Beat Takeshi, sumimasen. Fixes #31023. Change-Id: Ie2f27a5867724a8a1b8c3082c3389c8fd6d1dee7 Reviewed-on: https://go-review.googlesource.com/c/go/+/168861 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
* fmt: update formatting example for mapsRob Pike2018-11-261-7/+6
| | | | | | | | | | Now that maps are printed in deterministic order, the map example can have multiple keys without breaking the build. Change-Id: Iccec0cd76a3d41c75d8d4eb768ec0ac09ad9f2ad Reviewed-on: https://go-review.googlesource.com/c/151218 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
* fmt: add example SscanfLehner Florian2018-10-061-0/+13
| | | | | | | | | | | | Updates golang/go#27554. Change-Id: I2bf3d57ebeeb5dd50beffbc643a4ad10287b2c1e GitHub-Last-Rev: 4ffae55b4b2ca9d9b2a5b2b6dcef14ce43d83544 GitHub-Pull-Request: golang/go#27954 Reviewed-on: https://go-review.googlesource.com/c/138837 Reviewed-by: Rob Pike <r@golang.org> Run-TryBot: Rob Pike <r@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
* fmt: unify the printing examplesRob Pike2018-09-241-61/+132
| | | | | | | | | | | | | | | | | | | Provide an example for each of the printing functions (Print, Sprintf, Fprintln etc.), and make them all produce the same output so their usage can be compared. Also add a package-level example explaining the difference between how Printf, Println, and Print behave. There are more examples to come. Update #27554. Change-Id: Ide03e5233f3762a9ee2ac0269f534ab927562ce2 Reviewed-on: https://go-review.googlesource.com/136615 Reviewed-by: Ian Lance Taylor <iant@golang.org> Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
* fmt: add a package-level example illustrating basic formatsRob Pike2018-09-241-0/+149
| | | | | | | | | | | | There is much left out here—the space of possibilities is very large—but this example shows all that most programmers will need to know for most printing problems. Update #27554. Change-Id: Ib6ae651d5c3720cf7fe1a05ffd0859a5b56a9157 Reviewed-on: https://go-review.googlesource.com/136616 Reviewed-by: Ian Lance Taylor <iant@golang.org>
* fmt: add example for SprintThanabodee Charoenpiriyakij2018-09-071-0/+9
| | | | | | | | | | Updates #27376 Change-Id: I9ce6541a95b5ecd13f3932558427de1f597df07a Reviewed-on: https://go-review.googlesource.com/134036 Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
* fmt: add example for PrintThanabodee Charoenpiriyakij2018-09-071-0/+11
| | | | | | | | | | Updates #27376 Change-Id: I2fa63b0d1981a419626072d985e6f3326f6013ff Reviewed-on: https://go-review.googlesource.com/134035 Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
* fmt: add example for FprintThanabodee Charoenpiriyakij2018-09-071-0/+11
| | | | | | | | | | Updates #27376 Change-Id: I0ceb672a9fcd7bbf491be1577d7f135ef35b2561 Reviewed-on: https://go-review.googlesource.com/133455 Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
* fmt: add example for FscanlnMuhammad Falak R Wani2018-08-311-0/+23
| | | | | | | | | | Updates golang/go#27376. Change-Id: I9f33233f1aafa10941a63fcb4e49d351ea7ee246 Reviewed-on: https://go-review.googlesource.com/132675 Reviewed-by: Kevin Burke <kev@inburke.com> Run-TryBot: Kevin Burke <kev@inburke.com> TryBot-Result: Gobot Gobot <gobot@golang.org>
* fmt: add example for FscanfVenil Noronha2018-08-311-0/+19
| | | | | | | | Change-Id: Ia3dcb3a82e452fdcf0d087e8cd01ac01ca831c84 Reviewed-on: https://go-review.googlesource.com/132597 Reviewed-by: Joe Tsai <thebrokentoaster@gmail.com> Reviewed-by: Kevin Burke <kev@inburke.com> Run-TryBot: Joe Tsai <thebrokentoaster@gmail.com>
* fmt: add an example for SprintlnDrew Flower2018-08-311-0/+8
| | | | | | | | Change-Id: I0fcb5e626bf3d6891592c21b912c824743d7eaa0 Reviewed-on: https://go-review.googlesource.com/132280 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
* fmt: add Println exampleRodolfo Rodriguez2018-08-311-0/+11
| | | | | | | | Change-Id: Ifd509c0c6a6ea41094b6ae1f4931414325b152fd Reviewed-on: https://go-review.googlesource.com/132475 Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
* fmt: remove spelling mistake in exampleKevin Burke2018-08-301-1/+1
| | | | | | | | | | | | | "someting" is misspelled and the error handling both clobbers the error that occurs and distracts from the point of the example, which is to demonstrate how Printf works. It's better to just panic with the error. Change-Id: I5fb0a4a1a8b4772cbe0302582fa878d95e3a4060 Reviewed-on: https://go-review.googlesource.com/132376 Reviewed-by: Daniel Martí <mvdan@mvdan.cc> Run-TryBot: Daniel Martí <mvdan@mvdan.cc> TryBot-Result: Gobot Gobot <gobot@golang.org>
* fmt: add example for FprintlnDylan Waits2018-08-301-0/+12
| | | | | | | | Change-Id: Idc4aa53e443b89eeba496d00f6b409268e29ec21 Reviewed-on: https://go-review.googlesource.com/132241 Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
* fmt: add an example for Errorfianzapolsky2018-08-301-18/+7
| | | | | | | | | | | | The errors package has an example for Errorf, but the fmt package does not. Copy the Errorf example from errors to fmt. Move existing Stringer example into separate file, so as not to break the assumption that the entire file will be presented as the example. Change-Id: I8a210a69362017fa08615a8c3feccdeee8427e22 Reviewed-on: https://go-review.googlesource.com/132239 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
* fmt: add an example for SprintfVenil Noronha2018-08-301-0/+11
| | | | | | | | | | Signed-off-by: Venil Noronha <veniln@vmware.com> Change-Id: Ie5f50bc31db1eee11582b70b0e25c726090d4037 Reviewed-on: https://go-review.googlesource.com/132236 Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
* fmt: add Stringer exampleBlain Smith2017-08-161-0/+29
Change-Id: I901f995f8aedee47c48252745816e53192d4b7e4 Reviewed-on: https://go-review.googlesource.com/49090 Reviewed-by: Sam Whited <sam@samwhited.com> Reviewed-by: Ian Lance Taylor <iant@golang.org> Run-TryBot: Sam Whited <sam@samwhited.com> TryBot-Result: Gobot Gobot <gobot@golang.org>