Source File
format.go
Belonging Package
fmt
:= [:]
for := range {
[] =
}
*.buf = [:]
}
.writePadding()
.buf.write()
.buf.write()
.writePadding()
}
}
func ( *fmt) ( string) {
if !.widPresent || .wid == 0 {
.buf.writeString()
return
}
:= .wid - utf8.RuneCountInString()
.writePadding()
.buf.writeString()
.buf.writeString()
.writePadding()
}
}
:= 4
if .precPresent && .prec > 4 {
:= len()
for > 0 {
--
[] = '0'
--
:= 0
if .precPresent {
switch {
case 10:
for >= 10 {
--
:= / 10
[] = byte('0' + - *10)
=
}
case 16:
for >= 16 {
--
[] = [&0xF]
>>= 4
}
case 8:
for >= 8 {
--
[] = byte('0' + &7)
>>= 3
}
case 2:
for >= 2 {
--
[] = byte('0' + &1)
>>= 1
}
default:
panic("fmt: unknown base; can't happen")
}
--
[] = []
for > 0 && > len()- {
--
[] = '0'
}
if .sharp {
switch {
--
[] = 'b'
--
[] = '0'
case 8:
if [] != '0' {
--
[] = '0'
}
func ( *fmt) ( string) string {
if .precPresent {
:= .prec
for := range {
--
if < 0 {
return [:]
}
}
}
return
}
func ( *fmt) ( []byte) []byte {
if .precPresent {
:= .prec
for := 0; < len(); {
--
if < 0 {
return [:]
}
:= 1
if [] >= utf8.RuneSelf {
_, = utf8.DecodeRune([:])
}
+=
}
}
return
}
func ( *fmt) ( string) {
= .truncateString()
.padString()
}
= len()
if .precPresent && .prec < {
= .prec
:= 2 *
if > 0 {
if .sharp {
*= 2
+= - 1
+= 2
}
} else { // The byte slice or string that should be encoded is empty.
if .widPresent {
.writePadding(.wid)
}
return
if .widPresent && .wid > && !.minus {
.writePadding(.wid - )
:= *.buf
= append(, ' ')
= append(, [>>4], [&0xF])
}
if .widPresent && .wid > && .minus {
.writePadding(.wid - )
}
}
func ( *fmt) ( string) {
= .truncateString()
if .sharp && strconv.CanBackquote() {
.padString("`" + + "`")
return
}
:= .intbuf[:0]
if .plus {
.pad(strconv.AppendQuoteToASCII(, ))
} else {
.pad(strconv.AppendQuote(, ))
}
}
if .precPresent {
= .prec
:= strconv.AppendFloat(.intbuf[:1], , byte(), , )
if [1] == '-' || [1] == '+' {
= [1:]
} else {
[0] = '+'
if [1] == 'I' || [1] == 'N' {
:= .zero
if .sharp && != 'b' {
:= 0
switch {
case 'v', 'g', 'G', 'x':
if == -1 {
= 6
}
}
if {
--
}
}
}
.pad([1:])
![]() |
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. |