LEFT | RIGHT |
(no file at all) | |
1 // Copyright 2009 The Go Authors. All rights reserved. | 1 // Copyright 2009 The Go Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style | 2 // Use of this source code is governed by a BSD-style |
3 // license that can be found in the LICENSE file. | 3 // license that can be found in the LICENSE file. |
4 | 4 |
5 package fmt | 5 package fmt |
6 | 6 |
7 import ( | 7 import ( |
8 "bytes" | 8 "bytes" |
9 "io" | 9 "io" |
10 "os" | 10 "os" |
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
178 p := newPrinter() | 178 p := newPrinter() |
179 p.doPrintf(format, a) | 179 p.doPrintf(format, a) |
180 s := p.buf.String() | 180 s := p.buf.String() |
181 p.free() | 181 p.free() |
182 return s | 182 return s |
183 } | 183 } |
184 | 184 |
185 // Errorf formats according to a format specifier and returns the string· | 185 // Errorf formats according to a format specifier and returns the string· |
186 // converted to an os.ErrorString, which satisfies the os.Error interface. | 186 // converted to an os.ErrorString, which satisfies the os.Error interface. |
187 func Errorf(format string, a ...interface{}) os.Error { | 187 func Errorf(format string, a ...interface{}) os.Error { |
188 » return os.ErrorString(Sprintf(format, a...)) | 188 » return os.NewError(Sprintf(format, a...)) |
189 } | 189 } |
190 | 190 |
191 // These routines do not take a format string | 191 // These routines do not take a format string |
192 | 192 |
193 // Fprint formats using the default formats for its operands and writes to w. | 193 // Fprint formats using the default formats for its operands and writes to w. |
194 // Spaces are added between operands when neither is a string. | 194 // Spaces are added between operands when neither is a string. |
195 // It returns the number of bytes written and any write error encountered. | 195 // It returns the number of bytes written and any write error encountered. |
196 func Fprint(w io.Writer, a ...interface{}) (n int, error os.Error) { | 196 func Fprint(w io.Writer, a ...interface{}) (n int, error os.Error) { |
197 p := newPrinter() | 197 p := newPrinter() |
198 p.doPrint(a, false, false) | 198 p.doPrint(a, false, false) |
(...skipping 737 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
936 if addspace || !isString && !prevString { | 936 if addspace || !isString && !prevString { |
937 p.buf.WriteByte(' ') | 937 p.buf.WriteByte(' ') |
938 } | 938 } |
939 } | 939 } |
940 prevString = p.printField(field, 'v', false, false, 0) | 940 prevString = p.printField(field, 'v', false, false, 0) |
941 } | 941 } |
942 if addnewline { | 942 if addnewline { |
943 p.buf.WriteByte('\n') | 943 p.buf.WriteByte('\n') |
944 } | 944 } |
945 } | 945 } |
LEFT | RIGHT |