GoPLS Viewer

Home|gopls/go/ssa/interp/testdata/src/fmt/fmt.go
1package fmt
2
3import (
4    "errors"
5    "strings"
6)
7
8func Sprint(args ...interface{}) string
9
10func Sprintln(args ...interface{}) string {
11    return Sprint(args...) + "\n"
12}
13
14func Print(args ...interface{}) (interror) {
15    var n int
16    for iarg := range args {
17        if i > 0 {
18            print(" ")
19            n++
20        }
21        msg := Sprint(arg)
22        n += len(msg)
23        print(msg)
24    }
25    return nnil
26}
27
28func Println(args ...interface{}) {
29    Print(args...)
30    println()
31}
32
33// formatting is too complex to fake
34// handle the bare minimum needed for tests
35
36func Printf(format stringargs ...interface{}) (interror) {
37    msg := Sprintf(formatargs...)
38    print(msg)
39    return len(msg), nil
40}
41
42func Sprintf(format stringargs ...interface{}) string {
43    // handle extremely simple cases that appear in tests.
44    if len(format) == 0 {
45        return ""
46    }
47    switch {
48    case strings.HasPrefix("%v"format) || strings.HasPrefix("%s"format):
49        return Sprint(args[0]) + Sprintf(format[2:], args[1:]...)
50    case !strings.HasPrefix("%"format):
51        return format[:1] + Sprintf(format[1:], args...)
52    default:
53        panic("unsupported format string for testing Sprintf")
54    }
55}
56
57func Errorf(format stringargs ...interface{}) error {
58    msg := Sprintf(formatargs...)
59    return errors.New(msg)
60}
61
MembersX
Sprint.args
Sprintln.args
Print.args
Print.n
Println.args
Printf
errors
strings
Printf.args
Sprintf.args
Println
Errorf.args
Errorf.msg
Sprint
Print.RangeStmt_225.i
Printf.msg
Sprintf.format
Errorf
Errorf.format
Print
Printf.format
Print.RangeStmt_225.BlockStmt.msg
Sprintf
Sprintln
Print.RangeStmt_225.arg
Members
X