Source File
adaptor.go
Belonging Package
golang.org/x/xerrors
package xerrors
import (
)
case 'v':
if .Flag('#') {
if , := .(fmt.GoStringer); {
io.WriteString(&.buf, .GoString())
goto
} else if .Flag('+') {
.printDetail = true
= "\n - "
}
case 's':
= false
default:
.buf.WriteString("%!")
.buf.WriteRune()
.buf.WriteByte('(')
switch {
case != nil:
.buf.WriteString(reflect.TypeOf().String())
default:
.buf.WriteString("<nil>")
}
.buf.WriteByte(')')
io.Copy(, &.buf)
return
}
:
for {
switch v := .(type) {
case Formatter:
= .FormatError((*printer)())
case fmt.Formatter:
.Format(, 'v')
break
default:
io.WriteString(&.buf, .Error())
break
}
if == nil {
break
}
if .needColon || !.printDetail {
.buf.WriteByte(':')
.needColon = false
}
.buf.WriteString()
.inDetail = false
.needNewline = false
}
:
, := .Width()
, := .Precision()
:= []byte{'%'}
if .Flag('-') {
= append(, '-')
}
if .Flag('+') {
= append(, '+')
}
if .Flag(' ') {
= append(, ' ')
}
if {
= strconv.AppendInt(, int64(), 10)
}
if {
= append(, '.')
= strconv.AppendInt(, int64(), 10)
}
= append(, string()...)
fmt.Fprintf(, string(), .buf.String())
} else {
io.Copy(, &.buf)
}
}
var detailSep = []byte("\n ")
type state struct {
fmt.State
buf bytes.Buffer
printDetail bool
inDetail bool
needColon bool
needNewline bool
}
func ( *state) ( []byte) ( int, error) {
if .printDetail {
if len() == 0 {
return 0, nil
}
if .inDetail && .needColon {
.needNewline = true
if [0] == '\n' {
= [1:]
}
}
:= 0
for , := range {
if .needNewline {
if .inDetail && .needColon {
.buf.WriteByte(':')
.needColon = false
}
.buf.Write(detailSep)
.needNewline = false
}
if == '\n' {
.buf.Write([:])
= + 1
.needNewline = true
}
}
.buf.Write([:])
if !.inDetail {
.needColon = true
}
} else if !.inDetail {
.buf.Write()
}
return len(), nil
}
![]() |
The pages are generated with Golds v0.3.2-preview. (GOOS=darwin GOARCH=amd64) Golds is a Go 101 project developed by Tapir Liu. PR and bug reports are welcome and can be submitted to the issue list. Please follow @Go100and1 (reachable from the left QR code) to get the latest news of Golds. |