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 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
244 | 244 |
245 // Sprintln formats using the default formats for its operands and returns the r
esulting string. | 245 // Sprintln formats using the default formats for its operands and returns the r
esulting string. |
246 // Spaces are always added between operands and a newline is appended. | 246 // Spaces are always added between operands and a newline is appended. |
247 func Sprintln(a ...interface{}) string { | 247 func Sprintln(a ...interface{}) string { |
248 p := newPrinter() | 248 p := newPrinter() |
249 p.doPrint(a, true, true) | 249 p.doPrint(a, true, true) |
250 s := p.buf.String() | 250 s := p.buf.String() |
251 p.free() | 251 p.free() |
252 return s | 252 return s |
253 } | 253 } |
254 | |
255 | 254 |
256 // Get the i'th arg of the struct value. | 255 // Get the i'th arg of the struct value. |
257 // If the arg itself is an interface, return a value for | 256 // If the arg itself is an interface, return a value for |
258 // the thing inside the interface, not the interface itself. | 257 // the thing inside the interface, not the interface itself. |
259 func getField(v reflect.Value, i int) reflect.Value { | 258 func getField(v reflect.Value, i int) reflect.Value { |
260 val := v.Field(i) | 259 val := v.Field(i) |
261 if i := val; i.Kind() == reflect.Interface { | 260 if i := val; i.Kind() == reflect.Interface { |
262 if inter := i.Interface(); inter != nil { | 261 if inter := i.Interface(); inter != nil { |
263 return reflect.ValueOf(inter) | 262 return reflect.ValueOf(inter) |
264 } | 263 } |
(...skipping 671 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
936 if addspace || !isString && !prevString { | 935 if addspace || !isString && !prevString { |
937 p.buf.WriteByte(' ') | 936 p.buf.WriteByte(' ') |
938 } | 937 } |
939 } | 938 } |
940 prevString = p.printField(field, 'v', false, false, 0) | 939 prevString = p.printField(field, 'v', false, false, 0) |
941 } | 940 } |
942 if addnewline { | 941 if addnewline { |
943 p.buf.WriteByte('\n') | 942 p.buf.WriteByte('\n') |
944 } | 943 } |
945 } | 944 } |
LEFT | RIGHT |