本文整理汇总了Golang中fmt.State类的典型用法代码示例。如果您正苦于以下问题:Golang State类的具体用法?Golang State怎么用?Golang State使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。

在下文中一共展示了State类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。

示例1: Format

func (v value) Format(f fmt.State, c rune) {
    if debug || f.Flag('#') {
        fmt.Fprintf(f, "%s["+v.format+"]", typeName(v.v), v.v)
    } else {
        fmt.Fprintf(f, v.format, v.v)
    }
}

开发者ID:zxpbenson,项目名称:rog-go,代码行数:7,代码来源:calc.go

示例2: Format

// Format satisfies the fmt.Formatter interface.
func (f formatter) Format(fs fmt.State, c rune) {
    if c == 'v' && fs.Flag('#') {
        fmt.Fprintf(fs, "%#v", f.matrix)
        return
    }
    format(f.matrix, f.prefix, f.margin, f.dot, f.squeeze, fs, c)
}

开发者ID:lessc0de,项目名称:matrix,代码行数:8,代码来源:format.go

示例3: Format

// Format is a support routine for fmt.Formatter. It accepts
// the formats 'b' (binary), 'o' (octal), 'd' (decimal), 'x'
// (lowercase hexadecimal), and 'X' (uppercase hexadecimal).
//
func (x *Int) Format(s fmt.State, ch int) {
    cs := charset(ch)

    // special cases
    switch {
    case cs == "":
        // unknown format
        fmt.Fprintf(s, "%%!%c(big.Int=%s)", ch, x.String())
        return
    case x == nil:
        fmt.Fprint(s, "<nil>")
        return
    }

    // determine format
    format := "%s"
    if s.Flag('#') {
        switch ch {
        case 'o':
            format = "0%s"
        case 'x':
            format = "0x%s"
        case 'X':
            format = "0X%s"
        }
    }
    if x.neg {
        format = "-" + format
    }

    fmt.Fprintf(s, format, x.abs.string(cs))
}

开发者ID:go-nosql,项目名称:golang,代码行数:36,代码来源:int.go

示例4: Format

func (fo formatter) Format(f fmt.State, c rune) {
    if c == 'v' && f.Flag('#') && f.Flag(' ') {
        fo.format(f)
        return
    }
    fo.passThrough(f, c)
}

开发者ID:rjmcguire,项目名称:pretty,代码行数:7,代码来源:formatter.go

###
示例5: Format


// Format formats the frame according to the fmt.Formatter interface.
//
//    %s    source file
//    %d    source line
//    %n    function name
//    %v    equivalent to %s:%d
//
// Format accepts flags that alter the printing of some verbs, as follows:
//
//    %+s   path of source file relative to the compile time GOPATH
//    %+v   equivalent to %+s:%d
func (f Frame) Format(s fmt.State, verb rune) {
    switch verb {
    case 's':
        switch {
        case s.Flag('+'):
            pc := f.pc()
            fn := runtime.FuncForPC(pc)
            if fn == nil {
                io.WriteString(s, "unknown")
            } else {
                file, _ := fn.FileLine(pc)
                fmt.Fprintf(s, "%s\n\t%s", fn.Name(), file)
            }
        default:
            io.WriteString(s, path.Base(f.file()))
        }
    case 'd':
        fmt.Fprintf(s, "%d", f.line())
    case 'n':
        name := runtime.FuncForPC(f.pc()).Name()
        io.WriteString(s, funcname(name))
    case 'v':
        f.Format(s, 's')
        io.WriteString(s, ":")
        f.Format(s, 'd')
    }
}

开发者ID:CadeLaRen,项目名称:docker-3,代码行数:38,代码来源:stack.go

最后编辑: kuteng  文档更新时间: 2021-08-23 19:14   作者:kuteng