summaryrefslogtreecommitdiff
path: root/src/fmt/print.go
Commit message (Collapse)AuthorAgeFilesLines
* all: use reflect.{Pointer,PointerTo}Cuong Manh Le2021-10-261-3/+3
| | | | | | | | | | | | Updates #47651 Updates #48665 Change-Id: I69a87b45a5cad7a07fbd855040cd9935cf874554 Reviewed-on: https://go-review.googlesource.com/c/go/+/358454 Trust: Cuong Manh Le <cuong.manhle.vn@gmail.com> Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
* fmt: explain how Formatter interface affects verbs and flagsBryan Boreham2020-10-131-4/+4
| | | | | | | | | | | | | | | | | Formatter is mentioned further down, but it's helpful to add it amongst the verbs and flags. Background: I spent a while puzzling how "%+v" prints a stack trace for github.com/pkg/errors when this isn't documented under 'flags'. Change-Id: Ic70145902a36780147dedca568b3cf482974fc38 GitHub-Last-Rev: 6571b499f211a2266812af66dd3b88dff602cabf GitHub-Pull-Request: golang/go#39860 Reviewed-on: https://go-review.googlesource.com/c/go/+/240000 Reviewed-by: Rob Pike <r@golang.org> Trust: Rob Pike <r@golang.org> Trust: Ian Lance Taylor <iant@golang.org>
* fmt: avoid badverb formatting for %q when used with integersMartin Möhrmann2020-08-171-5/+1
| | | | | | | | | | | | | | | | Instead of returning a bad verb error format for runes above utf8.Maxrune return a quoted utf8.RuneError rune (\ufffd). This makes the behaviour consistent with the "c" verb and aligns behaviour to not return bad verb error format when a verb is applied to the correct argument type. Fixes #14569 Change-Id: I679485f6bb90ebe408423ab68af16cce38816cd0 Reviewed-on: https://go-review.googlesource.com/c/go/+/248759 Run-TryBot: Martin Möhrmann <moehrmann@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Rob Pike <r@golang.org>
* fmt: always clear wrapErrsMartin Möhrmann2019-05-231-1/+2
| | | | | | | | | | | Like panicking and erroring - wrapErrs should always be reset to the default false. wrapErrs should only be true when set by Errorf. Change-Id: I4d51cc2f0905109e232b0983dc5331bd34f138bc Reviewed-on: https://go-review.googlesource.com/c/go/+/178517 Run-TryBot: Martin Möhrmann <moehrmann@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Damien Neil <dneil@google.com>
* fmt: support %wDamien Neil2019-05-151-7/+20
| | | | | | | | | | | | | | When fmt.Errorf is provided with a %w verb with an error operand, return an error implementing an Unwrap method returning that operand. It is invalid to use %w with other formatting functions, to use %w multiple times in a format string, or to use %w with a non-error operand. When the Errorf format string contains an invalid use of %w, the returned error does not implement Unwrap. Change-Id: I534e20d3b163ab22c2b137b1c9095906dc243221 Reviewed-on: https://go-review.googlesource.com/c/go/+/176998 Reviewed-by: Marcel van Lohuizen <mpvl@golang.org>
* errors, fmt: revert rejected changes for Go 1.13Damien Neil2019-05-151-14/+21
| | | | | | | | | | | | | | | | | | | | | | | Reverts the following changes: https://go.googlesource.com/go/+/1f90d081391d4f5911960fd28d81d7ea5e554a8f https://go.googlesource.com/go/+/8bf18b56a47a98b9dd2fa03beb358312237a8c76 https://go.googlesource.com/go/+/5402854c3557f87fa2741a52ffc15dfb1ef333cc https://go.googlesource.com/go/+/37f84817247d3b8e687a701ccb0d6bc7ffe3cb78 https://go.googlesource.com/go/+/6be6f114e0d483a233101a67c9644cd72bd3ae7a Partially reverts the followinng change, removing the errors.Opaque function and the errors.Wrapper type definition: https://go.googlesource.com/go/+/62f5e8156ef56fa61e6af56f4ccc633bde1a9120 Updates documentation referencing the Wrapper type. Change-Id: Ia622883e39cafb06809853e3fd90b21441124534 Reviewed-on: https://go-review.googlesource.com/c/go/+/176997 Run-TryBot: Damien Neil <dneil@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Marcel van Lohuizen <mpvl@golang.org>
* fmt: rename buffer.WriteByte to writeByteRuss Cox2019-05-091-91/+91
| | | | | | | | | | | | | | | | | Renaming the method makes clear, both to readers and to vet, that this method is not the implementation of io.ByteWriter. Working toward making the tree vet-safe instead of having so many exceptions in cmd/vet/all/whitelist. For #31916. Change-Id: I79da062ca6469b62a6b9e284c6cf2413c7425249 Reviewed-on: https://go-review.googlesource.com/c/go/+/176109 Run-TryBot: Russ Cox <rsc@golang.org> Reviewed-by: Austin Clements <austin@google.com> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
* fmt: add frame info to Errorf and support %wMarcel van Lohuizen2019-02-271-21/+14
| | | | | | | | | | Partly implements proposal Issue #29934. Change-Id: Ibcf12f383158dcfbc313ab29c417a710571d1acb Reviewed-on: https://go-review.googlesource.com/c/163559 Run-TryBot: Marcel van Lohuizen <mpvl@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Damien Neil <dneil@google.com>
* fmt: format 0b, 0o prefixes in %#b and %ORuss Cox2019-02-261-9/+9
| | | | | | | | | | | | | | | | | This CL modifies fmt's printer to implement %#b and %O to emit leading 0b and 0o prefixes on binary and octal. (%#o is already taken and emits "0377"; %O emits "0o377".) See golang.org/design/19308-number-literals for background. For #19308. For #12711. Vet update is #29986. Change-Id: I7c38a4484c48a03abe9f6d45c7d981c7c314f583 Reviewed-on: https://go-review.googlesource.com/c/160246 Reviewed-by: Robert Griesemer <gri@golang.org> Reviewed-by: Rob Pike <r@golang.org>
* fmt: format hex floats and complexesRuss Cox2019-02-261-2/+2
| | | | | | | | | | | | | | | | This CL modifies fmt's printer to implement %x and %X for formatting floating-point data (floats and complexes) in standard hexadecimal notation. See golang.org/design/19308-number-literals for background. For #29008. Vet update is #29986. Change-Id: If2842a11631bc393a1ebcf6914ed07658652af5a Reviewed-on: https://go-review.googlesource.com/c/160245 Reviewed-by: Robert Griesemer <gri@golang.org> Reviewed-by: Rob Pike <r@golang.org>
* fmt: include failing method name in panic messageIan Lance Taylor2018-12-131-5/+7
| | | | | | | | | | Fixes #25707 Change-Id: Idfa379db8cc0e105ea68455ec0b4a0dbc1b3f485 Reviewed-on: https://go-review.googlesource.com/c/153827 Run-TryBot: Ian Lance Taylor <iant@golang.org> Reviewed-by: Rob Pike <r@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
* fmt: avoid allocation when formatting byte slice arguments with verb sMartin Möhrmann2018-11-141-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | fmtBytes is in the top 10 callers of runtime.slicebytetostring according to Google wide profiling data. Avoid the string conversion of the input byte slice in fmtBytes by calling a newly added specialized fmtS function for byte slices. Expand tests for verb s with widths to test strings and byte slice arguments. SprintfTruncateString 157ns ± 4% 156ns ± 3% ~ (p=0.122 n=20+20) SprintfTruncateBytes 188ns ± 2% 155ns ± 3% -18.00% (p=0.000 n=20+19) name old alloc/op new alloc/op delta SprintfTruncateString 16.0B ± 0% 16.0B ± 0% ~ (all equal) SprintfTruncateBytes 64.0B ± 0% 16.0B ± 0% -75.00% (p=0.000 n=20+20) name old allocs/op new allocs/op delta SprintfTruncateString 1.00 ± 0% 1.00 ± 0% ~ (all equal) SprintfTruncateBytes 2.00 ± 0% 1.00 ± 0% -50.00% (p=0.000 n=20+20) Change-Id: I461bf514d4232b39bd9c812f7faa4e5ef693a03b Reviewed-on: https://go-review.googlesource.com/c/145284 Run-TryBot: Martin Möhrmann <martisch@uos.de> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Rob Pike <r@golang.org>
* fmt: print maps in key-sorted orderRob Pike2018-10-181-4/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | For easier testing, change the way maps are printed so they appear in a consistent order between runs. Do this by printing them in key-sorted order. To do this, we add a package at the root, internal/fmtsort, that implements a general mechanism for sorting map keys regardless of their type. This is a little messy and probably slow, but formatted printing of maps has never been fast and is already always reflection-driven. The rules are: The ordering rules are more general than with Go's < operator: - when applicable, nil compares low - ints, floats, and strings order by < - NaN compares less than non-NaN floats - bool compares false before true - complex compares real, then imag - pointers compare by machine address - channel values compare by machine address - structs compare each field in turn - arrays compare each element in turn. - interface values compare first by reflect.Type describing the concrete type and then by concrete value as described in the previous rules. The new package is internal because we really do not want everyone using this to sort things. It is slow, not general, and only suitable for the subset of types that can be map keys. Also use the package in text/template, which already had a weaker version of this mechanism. This change requires adding a dependency on sort to the fmt package, but that isn't disruptive to the dependency tree. Fixes #21095 Change-Id: Ia602115c7de5d95993dbd609611d8bd96e054157 Reviewed-on: https://go-review.googlesource.com/c/142737 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Reviewed-by: Russ Cox <rsc@golang.org>
* fmt: fix usage of sync.PoolJoe Tsai2018-09-191-0/+10
| | | | | | | | | | | | | | | | | | | | | | The current usage of sync.Pool is leaky because it stores an arbitrary sized buffer into the pool. However, sync.Pool assumes that all items in the pool are interchangeable from a memory cost perspective. Due to the unbounded size of a buffer that may be added, it is possible for the pool to eventually pin arbitrarily large amounts of memory in a live-lock situation. As a simple fix, we just set a maximum size that we permit back into the pool. We do not need to fix the use of a sync.Pool in scan.go since the free method has always enforced a maximum capacity since the first commit of the scan logic. Fixes #27740 Updates #23199 Change-Id: I875278f7dba42625405df36df3e9b028252ce5e3 Reviewed-on: https://go-review.googlesource.com/136116 Reviewed-by: Bryan C. Mills <bcmills@google.com> Run-TryBot: Bryan C. Mills <bcmills@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org>
* fmt: print values for map keys with non-reflexive equalityMartin Möhrmann2018-08-221-4/+4
| | | | | | | | | | | | | | | | | | Previously fmt would first obtain a list of map keys and then look up the value for each key. Since NaNs can be map keys but cannot be fetched directly, the lookup would fail and return a zero reflect.Value, which formats as <nil>. golang.org/cl/33572 added a map iterator to the reflect package that is used in this CL to retrieve the key and value from the map and prints the correct value even for keys that are not equal to themselves. Fixes #14427 Change-Id: I9e1522959760b3de8b7ecf7a6e67cd603339632a Reviewed-on: https://go-review.googlesource.com/129777 Reviewed-by: Alan Donovan <adonovan@google.com>
* fmt: change some unexported method names to camel caseDarshan Parajuli2018-02-271-28/+28
| | | | | | Change-Id: I12f96a9397cfaebe11e616543d804bd62cd72da0 Reviewed-on: https://go-review.googlesource.com/97379 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
* fmt: Implement pp.WriteString methodRajath Agasthya2017-09-201-0/+7
| | | | | | | | | | | This allows io.WriteString to make use of WriteString method implemented by pp when writing a string to fmt.State. Fixes #20786 Change-Id: Ice7a92bf303127ad87f05562217fa076f5c589ad Reviewed-on: https://go-review.googlesource.com/61430 Reviewed-by: Rob Pike <r@golang.org>
* all: remove some double spaces from commentsDaniel Martí2017-08-261-1/+1
| | | | | | | | | | | Went mainly for the ones that make no sense, such as the ones mid-sentence or after commas. Change-Id: Ie245d2c19cc7428a06295635cf6a9482ade25ff0 Reviewed-on: https://go-review.googlesource.com/57293 Reviewed-by: Ian Lance Taylor <iant@golang.org> Run-TryBot: Daniel Martí <mvdan@mvdan.cc> TryBot-Result: Gobot Gobot <gobot@golang.org>
* fmt: add ascii fast path for decoding verbsMartin Möhrmann2017-08-141-2/+5
| | | | | | | | | | | name old time/op new time/op delta SprintfSlowParsingPath 108ns ± 4% 103ns ± 4% -4.53% (p=0.000 n=18+18) Change-Id: I174463f303d1857e8d5b8a6283c025b3546e7b39 Reviewed-on: https://go-review.googlesource.com/44450 Run-TryBot: Martin Möhrmann <moehrmann@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Rob Pike <r@golang.org>
* fmt: remove unused global variable byteTypeMartin Möhrmann2017-02-191-2/+0
| | | | | | | | | | | Change list https://golang.org/cl/20686/ removed the last use of the variable byteType. Change-Id: I4ea79095136a49a9d22767b37f48f3404da05056 Reviewed-on: https://go-review.googlesource.com/37197 Run-TryBot: Martin Möhrmann <moehrmann@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
* fmt: undo clearflags in catchPanic after error message has been printedMartin Möhrmann2016-12-111-1/+7
| | | | | | | | | | Fixes #18282 Change-Id: I024ca4a03bbbcccd48a0a6245bc3ec22c6a90288 Reviewed-on: https://go-review.googlesource.com/34254 TryBot-Result: Gobot Gobot <gobot@golang.org> Run-TryBot: Martin Möhrmann <moehrmann@google.com> Reviewed-by: Rob Pike <r@golang.org>
* fmt: remove unnecessary else statementOdin Ugedal2016-12-071-8/+7
| | | | | | | | Change-Id: If30ccfcf56d56fb40102ad567a980793bd39f320 Reviewed-on: https://go-review.googlesource.com/34071 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
* fmt: always handle special methods if print operand is a reflect.ValueMartin Möhrmann2016-10-181-0/+8
| | | | | | | | | | | | | Check for and call the special printing and format methods such as String at printing depth 0 when printing the concrete value of a reflect.Value. Fixes: #16015 Change-Id: I23bd2927255b60924e5558321e98dd4a95e11c4c Reviewed-on: https://go-review.googlesource.com/30753 Reviewed-by: Russ Cox <rsc@golang.org> Run-TryBot: Martin Möhrmann <martisch@uos.de> TryBot-Result: Gobot Gobot <gobot@golang.org>
* fmt: optimize struct layout and intbuf sizeMartin Möhrmann2016-04-151-6/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Move boolean fields to the end of the pp struct for better packing. Increase the fmt.intbuf size to leave no padding space unused at the end of the fmt struct on 32 bit architectures. The size of the pp struct on amd64 is decreased from 192 byte to 184 byte and on 386 from 132 byte to 128 byte. Simplify buffer size calculation in fmt_integer. Consolidate test cases for intbuf overflow checks. amd64 Haswell: name old time/op new time/op delta SprintfPadding-2 227ns ± 2% 227ns ± 1% ~ (p=0.941 n=25+25) SprintfEmpty-2 38.4ns ± 6% 35.8ns ±23% -6.71% (p=0.030 n=24+25) SprintfString-2 100ns ± 0% 101ns ± 0% +1.00% (p=0.000 n=19+18) SprintfTruncateString-2 142ns ± 1% 142ns ± 1% +0.37% (p=0.028 n=25+25) SprintfQuoteString-2 397ns ± 0% 393ns ± 0% -0.82% (p=0.000 n=21+24) SprintfInt-2 101ns ± 2% 102ns ± 4% ~ (p=0.159 n=21+24) SprintfIntInt-2 155ns ± 3% 155ns ± 3% ~ (p=0.934 n=25+25) SprintfPrefixedInt-2 252ns ± 2% 251ns ± 2% ~ (p=0.198 n=25+25) SprintfFloat-2 184ns ± 3% 179ns ± 2% -3.07% (p=0.000 n=24+25) SprintfComplex-2 532ns ± 2% 535ns ± 2% +0.64% (p=0.046 n=25+24) SprintfBoolean-2 90.5ns ± 3% 91.6ns ± 2% +1.17% (p=0.000 n=22+22) SprintfHexString-2 164ns ± 2% 165ns ± 3% ~ (p=0.066 n=25+25) SprintfHexBytes-2 171ns ± 3% 170ns ± 3% ~ (p=0.941 n=25+24) SprintfBytes-2 320ns ± 1% 313ns ± 1% -2.31% (p=0.000 n=24+21) SprintfStringer-2 347ns ± 2% 348ns ± 2% ~ (p=0.426 n=24+24) SprintfStructure-2 753ns ± 1% 742ns ± 1% -1.49% (p=0.000 n=24+25) FprintInt-2 145ns ± 0% 144ns ± 0% -0.69% (p=0.000 n=24+23) FprintfBytes-2 163ns ± 0% 163ns ± 0% -0.27% (p=0.000 n=25+25) FprintIntNoAlloc-2 108ns ± 0% 105ns ± 0% -2.78% (p=0.000 n=25+2 386 Haswell: name old time/op new time/op delta SprintfPadding-2 426ns ± 2% 422ns ± 1% -0.89% (p=0.000 n=25+24) SprintfEmpty-2 24.6ns ± 1% 24.5ns ± 0% -0.39% (p=0.000 n=22+15) SprintfString-2 99.1ns ± 3% 95.6ns ± 0% -3.52% (p=0.000 n=25+24) SprintfTruncateString-2 156ns ± 4% 153ns ± 1% -1.65% (p=0.000 n=24+23) SprintfQuoteString-2 500ns ± 2% 493ns ± 1% -1.49% (p=0.000 n=25+24) SprintfInt-2 92.6ns ± 9% 88.3ns ± 1% -4.72% (p=0.000 n=25+25) SprintfIntInt-2 143ns ± 7% 137ns ± 2% -4.01% (p=0.000 n=23+25) SprintfPrefixedInt-2 268ns ±19% 264ns ±16% ~ (p=0.826 n=24+24) SprintfFloat-2 242ns ± 4% 246ns ± 2% +1.60% (p=0.000 n=25+25) SprintfComplex-2 1.04µs ± 3% 1.03µs ± 1% -0.89% (p=0.026 n=25+25) SprintfBoolean-2 82.2ns ± 9% 80.7ns ± 2% ~ (p=0.163 n=24+24) SprintfHexString-2 240ns ± 5% 224ns ± 2% -6.94% (p=0.000 n=25+25) SprintfHexBytes-2 245ns ± 3% 234ns ± 2% -4.55% (p=0.000 n=25+25) SprintfBytes-2 432ns ±13% 419ns ± 2% ~ (p=0.081 n=23+25) SprintfStringer-2 356ns ± 4% 356ns ± 4% ~ (p=0.988 n=25+25) SprintfStructure-2 968ns ± 5% 948ns ± 2% -2.11% (p=0.000 n=25+25) FprintInt-2 206ns ± 0% 201ns ± 0% -2.43% (p=0.000 n=25+21) FprintfBytes-2 187ns ± 1% 187ns ± 1% ~ (p=0.420 n=25+25) FprintIntNoAlloc-2 173ns ± 0% 168ns ± 0% -2.89% (p=0.000 n=25+2 amd64 Ivy Bridge: name old time/op new time/op delta SprintfPadding-4 203ns ± 4% 210ns ± 8% +3.27% (p=0.000 n=23+25) SprintfEmpty-4 24.4ns ± 2% 24.4ns ± 3% ~ (p=0.487 n=24+25) SprintfString-4 92.4ns ± 2% 93.1ns ± 3% ~ (p=0.087 n=22+25) SprintfTruncateString-4 137ns ± 3% 136ns ± 2% -1.02% (p=0.002 n=25+25) SprintfQuoteString-4 378ns ± 1% 373ns ± 1% -1.32% (p=0.000 n=24+22) SprintfInt-4 89.9ns ± 3% 90.3ns ± 4% ~ (p=0.444 n=25+25) SprintfIntInt-4 137ns ± 4% 138ns ± 3% ~ (p=0.112 n=25+23) SprintfPrefixedInt-4 155ns ±14% 154ns ±14% ~ (p=0.791 n=25+25) SprintfFloat-4 154ns ± 2% 154ns ± 3% ~ (p=0.789 n=25+25) SprintfComplex-4 396ns ± 2% 402ns ± 3% +1.53% (p=0.001 n=23+25) SprintfBoolean-4 71.0ns ± 3% 71.2ns ± 2% ~ (p=0.515 n=25+24) SprintfHexString-4 156ns ± 3% 150ns ± 5% -3.69% (p=0.000 n=24+25) SprintfHexBytes-4 154ns ± 3% 157ns ± 5% +1.72% (p=0.003 n=24+25) SprintfBytes-4 297ns ± 4% 291ns ± 3% -1.86% (p=0.000 n=25+25) SprintfStringer-4 275ns ± 3% 265ns ± 3% -3.51% (p=0.000 n=25+25) SprintfStructure-4 878ns ± 2% 823ns ± 2% -6.21% (p=0.000 n=25+22) FprintInt-4 145ns ± 1% 147ns ± 2% +0.94% (p=0.001 n=23+25) FprintfBytes-4 166ns ± 1% 168ns ± 2% +0.81% (p=0.000 n=24+25) FprintIntNoAlloc-4 113ns ± 2% 109ns ± 2% -3.79% (p=0.000 n=24+25) 386 Ivy Bridge: name old time/op new time/op delta SprintfPadding-4 353ns ± 4% 354ns ± 4% ~ (p=0.769 n=25+24) SprintfEmpty-4 21.9ns ± 6% 21.1ns ± 3% -3.45% (p=0.000 n=24+25) SprintfString-4 94.7ns ± 1% 93.0ns ± 3% -1.77% (p=0.000 n=24+23) SprintfTruncateString-4 150ns ± 2% 147ns ± 0% -1.71% (p=0.000 n=25+21) SprintfQuoteString-4 472ns ± 1% 479ns ± 1% +1.48% (p=0.000 n=25+23) SprintfInt-4 87.0ns ± 2% 85.3ns ± 2% -1.95% (p=0.000 n=25+25) SprintfIntInt-4 137ns ± 2% 134ns ± 2% -1.97% (p=0.000 n=24+23) SprintfPrefixedInt-4 166ns ± 8% 161ns ± 8% -3.07% (p=0.023 n=24+24) SprintfFloat-4 226ns ± 1% 219ns ± 1% -2.97% (p=0.000 n=24+25) SprintfComplex-4 867ns ± 1% 784ns ± 1% -9.47% (p=0.000 n=24+23) SprintfBoolean-4 77.2ns ± 2% 76.0ns ± 2% -1.63% (p=0.000 n=25+25) SprintfHexString-4 212ns ± 2% 214ns ± 2% +0.96% (p=0.000 n=25+25) SprintfHexBytes-4 221ns ± 2% 218ns ± 1% -1.42% (p=0.000 n=25+24) SprintfBytes-4 423ns ± 3% 417ns ± 1% -1.49% (p=0.000 n=25+24) SprintfStringer-4 306ns ± 3% 298ns ± 3% -2.57% (p=0.000 n=24+25) SprintfStructure-4 1.00µs ± 2% 0.98µs ± 2% -1.34% (p=0.000 n=24+24) FprintInt-4 202ns ± 3% 197ns ± 2% -2.04% (p=0.000 n=25+25) FprintfBytes-4 186ns ± 2% 184ns ± 2% -0.88% (p=0.000 n=24+25) FprintIntNoAlloc-4 170ns ± 2% 166ns ± 2% -2.26% (p=0.000 n=24+25) Change-Id: I46e62bf8b6afa90a24f75b40f1d354b2084b910b Reviewed-on: https://go-review.googlesource.com/20984 Run-TryBot: Rob Pike <r@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Rob Pike <r@golang.org>
* fmt: hold on to all free buffers, regardless of sizeBrad Fitzpatrick2016-04-031-4/+0
| | | | | | | | | | | | This code made sense before fmt switched to using sync.Pool, but a sync.Pool clears all items on GC, so not reusing something based on size is just a waste of memory. Change-Id: I201312b0ee6c572ff3c0ffaf71e42623a160d23f Reviewed-on: https://go-review.googlesource.com/21480 Reviewed-by: Rob Pike <r@golang.org> Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
* fmt: unify array and slice formatting for bytes and other typesMartin Möhrmann2016-03-271-38/+35
| | | | | | | | | | | | | | | | | | | | | | | | Make verbs b,c,o and U work for any array and slice of integer type including byte and uint8. Fix a bug that triggers badverb for []uint8 and []byte type on the slice/array level instead of on each element like for any other slice or array type. Add tests that make sure we do not accidentally alter the behavior of printing []byte for []byte and []uint8 type if they are used at the top level when formatting with %#v. name old time/op new time/op delta SprintfHexBytes-2 177ns ± 2% 176ns ± 2% ~ (p=0.066 n=48+49) SprintfBytes-2 330ns ± 1% 329ns ± 1% ~ (p=0.118 n=45+47) Fixes #13478 Change-Id: I99328a184973ae219bcc0f69c3978cb1ff462888 Reviewed-on: https://go-review.googlesource.com/20686 Run-TryBot: Rob Pike <r@golang.org> Reviewed-by: Rob Pike <r@golang.org>
* fmt: cleanup reflect value handlingMartin Möhrmann2016-03-271-62/+37
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Merge printReflectValue into printValue. Determine if handleMethods was already called in printArg by checking if depth is 0. Do not call handleMethods on depth 0 again in printValue to not introduce a performance regression. handleMethods is called already in printArg to not introduce a performance penalty for top-level Stringer, GoStringer, Errors and Formatters by using reflect.ValueOf on them just to retrieve them again as interface{} values in printValue. Clear p.arg in printValue after handleMethods to print the type of the value inside the reflect.Value when a bad verb is encountered on the top level instead of printing "reflect.Value=" as the type of the argument. This also fixes a bug that incorrectly prints the whole map instead of just the value for a key if the returned value by the map for the key is an invalid reflect value. name old time/op new time/op delta SprintfPadding-2 229ns ± 2% 227ns ± 1% -0.50% (p=0.013 n=20+20) SprintfEmpty-2 36.4ns ± 6% 37.2ns ±14% ~ (p=0.091 n=18+20) SprintfString-2 102ns ± 1% 102ns ± 0% ~ (p=0.751 n=20+20) SprintfTruncateString-2 142ns ± 0% 141ns ± 1% -0.95% (p=0.000 n=16+20) SprintfQuoteString-2 389ns ± 0% 388ns ± 0% -0.12% (p=0.019 n=20+20) SprintfInt-2 100ns ± 2% 100ns ± 1% ~ (p=0.188 n=20+15) SprintfIntInt-2 155ns ± 3% 154ns ± 2% ~ (p=0.092 n=20+20) SprintfPrefixedInt-2 250ns ± 2% 251ns ± 3% ~ (p=0.559 n=20+20) SprintfFloat-2 177ns ± 2% 175ns ± 1% -1.30% (p=0.000 n=20+20) SprintfComplex-2 516ns ± 1% 510ns ± 1% -1.13% (p=0.000 n=19+16) SprintfBoolean-2 90.9ns ± 3% 90.6ns ± 1% ~ (p=0.193 n=19+19) SprintfHexString-2 171ns ± 1% 169ns ± 1% -1.44% (p=0.000 n=19+20) SprintfHexBytes-2 180ns ± 1% 180ns ± 1% ~ (p=0.060 n=19+18) SprintfBytes-2 330ns ± 1% 329ns ± 1% -0.42% (p=0.003 n=20+20) SprintfStringer-2 354ns ± 3% 352ns ± 3% ~ (p=0.525 n=20+19) SprintfStructure-2 804ns ± 3% 776ns ± 2% -3.56% (p=0.000 n=20+20) FprintInt-2 155ns ± 0% 151ns ± 1% -2.35% (p=0.000 n=19+20) FprintfBytes-2 169ns ± 0% 170ns ± 1% +0.81% (p=0.000 n=18+19) FprintIntNoAlloc-2 112ns ± 0% 109ns ± 1% -2.28% (p=0.000 n=20+20) Change-Id: Ib9a39082ed1be0f1f7499ee6fb6c9530f043e43a Reviewed-on: https://go-review.googlesource.com/20923 Run-TryBot: Rob Pike <r@golang.org> Reviewed-by: Rob Pike <r@golang.org>
* fmt: split doPrint into two specialized functionsMartin Möhrmann2016-03-261-11/+18
| | | | | | | | | | | | | | Remove format flag reset from doPrint. Flags will not be set in doPrint and printArg will not return with flags modified. Remove the extra arguments addspace and addnewline and split up doPrint into two simpler and specialized functions. Change-Id: Ib884d027abfbb31c6f01b008f51d6d76fc0c1a17 Reviewed-on: https://go-review.googlesource.com/21181 Run-TryBot: Rob Pike <r@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Rob Pike <r@golang.org>
* fmt: cleanup and optimize doPrintf for simple formatsMartin Möhrmann2016-03-231-41/+58
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Make a fast path for format strings that do not use precision or width specifications or argument indices. Only check and enforce the restriction to not pad left with zeros in code paths that change either f.minus or f.zero. Consolidate the if chains at the end of the main doPrintf loop into a switch statement. Move error printing into extra functions to reduce size of this switch statement. name old time/op new time/op delta SprintfPadding-2 234ns ± 1% 233ns ± 1% -0.54% (p=0.010 n=19+19) SprintfEmpty-2 37.0ns ± 3% 39.1ns ±14% ~ (p=0.501 n=17+20) SprintfString-2 112ns ± 1% 101ns ± 1% -9.21% (p=0.000 n=19+20) SprintfTruncateString-2 139ns ± 1% 139ns ± 0% +0.57% (p=0.000 n=19+19) SprintfQuoteString-2 402ns ± 0% 392ns ± 0% -2.35% (p=0.000 n=19+20) SprintfInt-2 114ns ± 1% 102ns ± 2% -10.92% (p=0.000 n=20+20) SprintfIntInt-2 177ns ± 2% 155ns ± 2% -12.67% (p=0.000 n=18+18) SprintfPrefixedInt-2 260ns ± 3% 249ns ± 3% -4.55% (p=0.000 n=20+20) SprintfFloat-2 190ns ± 1% 178ns ± 2% -6.54% (p=0.000 n=20+20) SprintfComplex-2 533ns ± 1% 517ns ± 3% -2.95% (p=0.000 n=20+20) SprintfBoolean-2 102ns ± 1% 93ns ± 2% -9.30% (p=0.000 n=20+20) SprintfHexString-2 176ns ± 0% 168ns ± 2% -4.49% (p=0.000 n=16+19) SprintfHexBytes-2 181ns ± 1% 174ns ± 2% -4.27% (p=0.000 n=20+20) SprintfBytes-2 326ns ± 1% 311ns ± 1% -4.51% (p=0.000 n=20+20) ManyArgs-2 540ns ± 2% 497ns ± 1% -8.08% (p=0.000 n=18+16) FprintInt-2 150ns ± 0% 149ns ± 0% -0.33% (p=0.000 n=20+18) FprintfBytes-2 185ns ± 0% 165ns ± 0% -10.98% (p=0.000 n=20+18) FprintIntNoAlloc-2 113ns ± 0% 112ns ± 0% -0.88% (p=0.000 n=20+20) Change-Id: I9ada8faa1f46aa67ea116a94ab3f4ad3e405c8fe Reviewed-on: https://go-review.googlesource.com/20919 Run-TryBot: Rob Pike <r@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Rob Pike <r@golang.org>
* fmt: unify integer formattingMartin Möhrmann2016-03-201-58/+32
| | | | | | | | | | | | | | | Deduplicate the verb switch for signed and unsigned integer formatting. Make names of integer related functions consistent with names of other fmt functions. Consolidate basic integer tests. Change-Id: I0c19c24f1c2c06a3b1a4d7d377dcdac3b36bb0f5 Reviewed-on: https://go-review.googlesource.com/20831 Run-TryBot: Rob Pike <r@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Rob Pike <r@golang.org>
* fmt: remove depth argument from handleMethods and printArgMartin Möhrmann2016-03-191-13/+13
| | | | | | | | | | | | | | | | handleMethods can format Error() and String() directly as its known these return strings that can be directly printed using fmtString. Remove the obsolete depth argument from handleMethods. Remove the depth argument from printArg since it is only ever called with depth set to 0. Recursion for formatting complex arguments is handled only by printValue which keeps track of depth. Change-Id: I4c4be588751de12ed999e7561a51bc168eb9eb2d Reviewed-on: https://go-review.googlesource.com/20911 Run-TryBot: Rob Pike <r@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Rob Pike <r@golang.org>
* fmt: simplify handling of reporting flags to formattersMartin Möhrmann2016-03-181-31/+2
| | | | | | | | | | | | Remove rewriting of flags before calling formatters. Change Flag method to directly take plusV and sharpV flags into account when reporting if plus or sharp flag is set. Change-Id: Ic3423881ad89e5a5f9fff5ab59e842062394ef6d Reviewed-on: https://go-review.googlesource.com/20859 Run-TryBot: Rob Pike <r@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Rob Pike <r@golang.org>
* fmt: remove unused field from printer structMartin Möhrmann2016-03-181-1/+0
| | | | | | | | Change-Id: I0ec775c51f461c6f0cbff88e796a7af55b736fcb Reviewed-on: https://go-review.googlesource.com/20838 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
* fmt: separate unicode and integer formattingMartin Möhrmann2016-03-171-24/+2
| | | | | | | | | | | | | | | | | | | | | | Separate unicode formatting into its own fmt_unicode function. Remove the fmtUnicode wrapper and the f.unicode and f.uniQuote flags that are not needed anymore. Remove mangling and restoring of the precision and sharp flags. Removes the buffer copy needed for %#U by moving the character encoding before the number encoding. Changes the behavior of plus and space flag to have no effect instead of printing a plus or space before "U+". Always print at least four digits after "U+" even if precision is set to less than 4. Change-Id: If9a0ee79e9eca2c76f06a4e0fdd75d98393899ac Reviewed-on: https://go-review.googlesource.com/20574 Run-TryBot: Rob Pike <r@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Rob Pike <r@golang.org>
* fmt: reuse buffer and add range checks for %c and %qMartin Möhrmann2016-03-161-15/+4
| | | | | | | | | | | | | | | | | | | | Use The fmt internal buffer for character formatting instead of the pp Printer rune decoding buffer. Uses an uint64 instead of int64 argument to fmt_c and fmt_qc for easier range checks since no valid runes are represented by negative numbers or are above 0x10ffff. Add range checks to fmt_c and fmt_qc to guarantee that a RuneError character is returned by the functions for any invalid code point in range uint64. For invalid code points in range utf8.MaxRune the used utf8 and strconv functions already return a RuneError. Change-Id: I9772f804dfcd79c3826fa7f6c5ebfbf4b5304a51 Reviewed-on: https://go-review.googlesource.com/20373 Run-TryBot: Rob Pike <r@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Rob Pike <r@golang.org>
* fmt: cleanup %p and %T code pathsMartin Möhrmann2016-03-161-15/+5
| | | | | | | | | | | | | | | | | Remove check for %p and %T in printValue. These verbs are not recursive and are handled already in printArg which is called on any argument before printValue. Format the type string for %T directly instead of invoking the more complex printArg with %s on the type string. Decouple the %T tests from variables declared in scan_test.go. Change-Id: Ibd51566bd4cc1a260ce6d052f36382ed05020b48 Reviewed-on: https://go-review.googlesource.com/20622 Run-TryBot: Rob Pike <r@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Rob Pike <r@golang.org>
* fmt: clear flags before printing extra argument errorsMartin Möhrmann2016-03-161-10/+11
| | | | | | | | | | | | | Do a reset of the fmt flags before printing the extra argument error message to prevent a malformed printing of extra arguments. Regroup tests for extra argument error strings. Change-Id: Ifd97f5ca36f6c97ed5a380d975cf154d17997d3f Reviewed-on: https://go-review.googlesource.com/20571 Run-TryBot: Rob Pike <r@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Rob Pike <r@golang.org>
* fmt: replace variables for type bit sizes with constantsMartin Möhrmann2016-03-161-5/+0
| | | | | | | | | | | | | Use constants instead of dynamically computed values to determine the bit sizes of types similar to how strconv and other packages directly compute these sizes. Move these constants near the code that uses them. Change-Id: I78d113b7e697466097e32653975df5990380c2c1 Reviewed-on: https://go-review.googlesource.com/20514 Run-TryBot: Rob Pike <r@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Rob Pike <r@golang.org>
* fmt: handle %X like %x for byte type arrays and slicesMartin Möhrmann2016-03-151-4/+6
| | | | | | | | | | | | | Treat the verb %X in the same special way as %q, %s and %x are for arrays and slices with byte type elements. Modify input for tests so the result of %x and %X is distinct. Change-Id: I38d227755e98c7fad5e4adc2f603c6873aa910fd Reviewed-on: https://go-review.googlesource.com/20516 Run-TryBot: Rob Pike <r@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Rob Pike <r@golang.org>
* fmt: refactor pointer formatting and improve testsMartin Möhrmann2016-03-091-28/+23
| | | | | | | | | | | | | | | | | | | | | | Uses a switch statement for direct format function selection similar to other types verb handling in fmt. Applies padding also to nil pointers formatted with %v. Guards against "slice bounds out of range" panic in TestSprintf when a pointer test results in a formatted string s that is shorter than the index i the pointer should appear in. Adds more and rearranges tests. Fixes #14712 Fixes #14714 Change-Id: Iaf5ae37b7e6ba7d27d528d199f2b2eb9d5829b8c Reviewed-on: https://go-review.googlesource.com/20371 Run-TryBot: Rob Pike <r@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Rob Pike <r@golang.org>
* fmt: refactor and unify float and complex formattingMartin Möhrmann2016-03-061-63/+37
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Removes specialized functions for each verb and float/complex size and replaces them with generic variants fmtFloat and fmtComplex similar to other generic fmt functions. Simplifies the complex formatting by relying on fmtFloat to handle the verb and default precision selection. Complex imaginary formatting does not need to clear the f.space flag because the set f.plus flag will force a sign instead of a space. Sets default precision for %b to -1 (same as %g and %G) since precision for %b has no affect in strconv.AppendFloat. Add more tests and group them a bit better. Use local copies of +Inf,-Inf and NaN instead of math package functions for testing. Saves around 8kb in the go binary. name old time/op new time/op delta SprintfFloat-2 200ns ± 4% 196ns ± 4% -1.55% (p=0.007 n=20+20) SprintfComplex-2 569ns ± 4% 570ns ± 3% ~ (p=0.804 n=20+20) Change-Id: I36d35dab6f835fc2bd2c042ac97705868eb2446f Reviewed-on: https://go-review.googlesource.com/20252 Reviewed-by: Rob Pike <r@golang.org> Run-TryBot: Rob Pike <r@golang.org>
* fmt: optimize byte slice and array formatting for %v and %dMartin Möhrmann2016-03-051-31/+19
| | | | | | | | | | | | | | | | | Instead of calling printArg in fmtBytes to format each byte call the byte formatting functions directly since it is known each element is of type byte. Add more tests for byte slice and array formatting. name old time/op new time/op delta SprintfBytes-2 843ns ±16% 417ns ±11% -50.58% (p=0.000 n=20+20) Change-Id: I5b907dbf52091e3de9710b09d67649c76f4c17e9 Reviewed-on: https://go-review.googlesource.com/20176 Run-TryBot: Rob Pike <r@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Rob Pike <r@golang.org>
* fmt: make identification of string arguments consistentMartin Möhrmann2016-03-011-35/+33
| | | | | | | | | | | | | | | | Use only reflect.TypeOf to detect if argument is a string. The wasString return is only needed in doPrint with the 'v' verb. This type of string detection is handled correctly by reflect.TypeOf which is used already in doPrint for identifying a string argument. Remove now obsolete wasString computations and return values. Change-Id: Iea2de7ac0f5c536a53eec63f7e679d628f5af8dc Reviewed-on: https://go-review.googlesource.com/19976 Run-TryBot: Rob Pike <r@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Rob Pike <r@golang.org>
* all: remove public named return values when uselessBrad Fitzpatrick2016-02-291-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* fmt: simplify buffer write methods and adjust calls to themMartin Möhrmann2016-02-271-76/+67
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Once upon a time fmt did use bytes.Buffer for its buffer. The buffer write methods still mimic the bytes.Buffer signatures. The current code depends on manipulating the buffer []bytes array directly which makes going back to bytes.Buffer by only changing the type of buffer impossible. Since type buffer is not exported the methods can be simplified to the needs of fmt. This saves space and avoids unnecessary overhead. Use WriteString instead of Write for known inputs since WriteString is faster than Write to append the same data. This also saves space in the binary. Remove the add method from Printer and depending on the data to be written use WriteRune or WriteByte directly instead. In total makes the go binary around 4 kilobyte smaller. name old time/op new time/op delta SprintfEmpty-2 24.1ns ± 3% 23.8ns ± 1% -1.14% (p=0.000 n=20+20) SprintfString-2 114ns ± 2% 114ns ± 4% ~ (p=0.558 n=20+19) SprintfInt-2 116ns ± 9% 118ns ± 7% ~ (p=0.086 n=20+20) SprintfIntInt-2 195ns ± 6% 193ns ± 5% ~ (p=0.345 n=20+19) SprintfPrefixedInt-2 251ns ±16% 241ns ± 9% -3.69% (p=0.024 n=20+19) SprintfFloat-2 203ns ± 4% 205ns ± 5% ~ (p=0.153 n=20+20) SprintfBoolean-2 101ns ± 7% 96ns ±11% -5.23% (p=0.005 n=19+20) ManyArgs-2 651ns ± 7% 628ns ± 7% -3.44% (p=0.002 n=20+20) FprintInt-2 164ns ± 2% 158ns ± 2% -3.62% (p=0.000 n=20+18) FprintfBytes-2 215ns ± 1% 216ns ± 1% +0.58% (p=0.000 n=20+20) FprintIntNoAlloc-2 115ns ± 0% 112ns ± 0% -2.61% (p=0.000 n=20+20) ScanInts-2 700µs ± 0% 702µs ± 1% +0.38% (p=0.000 n=18+20) ScanRecursiveInt-2 82.7ms ± 0% 82.7ms ± 0% ~ (p=0.820 n=20+20) Change-Id: I0409eb170b8a26d9f4eb271f6292e5d39faf2d8b Reviewed-on: https://go-review.googlesource.com/19955 Reviewed-by: Rob Pike <r@golang.org>
* fmt: change padding functions to avoid package initMartin Möhrmann2016-02-271-0/+6
| | | | | | | | | | | | | | | | | | | | | Move the decision if zero padding is allowed to doPrintf where the other formatting decisions are made. Removes some dead code for negative f.wid that was never used due to f.wid always being positive and f.minus deciding if left or right padding should be used. New padding code writes directly into the buffer and is as fast as the old version but avoids the cost of needing package init. name old time/op new time/op delta SprintfPadding-2 246ns ± 5% 245ns ± 4% ~ (p=0.345 n=50+47) Change-Id: I7dfddbac8e328f4ef0cdee8fafc0d06c784b2711 Reviewed-on: https://go-review.googlesource.com/19957 Run-TryBot: Rob Pike <r@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Rob Pike <r@golang.org>
* fmt: allow any type in a format's width argumentRob Pike2015-09-101-2/+21
| | | | | | | | | | | | | | | | | | | The construction fmt.Printf("%*d", n, 4) reads the argument n as a width specifier to use when printing 4. Until now, only strict int type was accepted here and it couldn't be fixed because the fix, using reflection, broke escape analysis and added an extra allocation in every Printf call, even those that do not use this feature. The compiler has been fixed, although I am not sure when exactly, so let's fix Printf and then write Fixes #10732. Change-Id: I79cf0c4fadd876265aa39d3cb62867247b36ab65 Reviewed-on: https://go-review.googlesource.com/14491 Reviewed-by: Ian Lance Taylor <iant@golang.org>
* fmt: handle negative width/prec when supplied as an argumentTodd Neal2015-06-251-3/+25
| | | | | | | | | | | | | | | | | | | | | | Negative width arguments now left align the way a minus-width in the format string aligns. The minus in the format string overrides the sign of the argument as in C. Precision behavior is modified to include an error if the argument is negative. This differs from a negative precision in a format string which just terminates the format. Additional checks for large magnitude widths and precisions are added to make the runtime behavior (failure, but with different error messages), more consistent between format string specified width/precision and argument specified width/precision. Fixes #11376 Change-Id: I8c7ed21088e9c18128a45d4c487c5ab9fafd13ef Reviewed-on: https://go-review.googlesource.com/11405 Reviewed-by: Rob Pike <r@golang.org> Run-TryBot: Rob Pike <r@golang.org>
* fmt: prevent panic from %.[]Fabrizio (Misto) Milo2015-05-051-2/+7
| | | | | | | | Fixes #10675 Change-Id: Ia057427ce3e81d35f1ba6c354868a0ad6cc9abf2 Reviewed-on: https://go-review.googlesource.com/9636 Reviewed-by: Rob Pike <r@golang.org>
* fmt: change the overflow test for large numbers in verbsRob Pike2015-05-051-2/+4
| | | | | | | | | | The old one was inferior. Fixes #10695. Change-Id: Ia7fb88c9ceb1b10197b77a54f729865385288d98 Reviewed-on: https://go-review.googlesource.com/9709 Reviewed-by: Dmitry Vyukov <dvyukov@google.com>