Source File
writer.go
Belonging Package
net/textproto
package textproto
import (
)
func ( *Writer) () io.WriteCloser {
.closeDot()
.dot = &dotWriter{w: }
return .dot
}
func ( *Writer) () {
if .dot != nil {
.dot.Close() // sets w.dot = nil
}
}
type dotWriter struct {
w *Writer
state int
}
const (
wstateBegin = iota // initial state; must be zero
wstateBeginLine // beginning of line
wstateCR // wrote \r (possibly at end of line)
wstateData // writing data in middle of line
)
func ( *dotWriter) ( []byte) ( int, error) {
:= .w.W
for < len() {
:= []
switch .state {
case wstateBegin, wstateBeginLine:
.state = wstateData
.WriteByte('.')
}
fallthrough
case wstateData:
if == '\r' {
.state = wstateCR
}
if == '\n' {
.WriteByte('\r')
.state = wstateBeginLine
}
case wstateCR:
.state = wstateData
if == '\n' {
.state = wstateBeginLine
}
}
if = .WriteByte(); != nil {
break
}
++
}
return
}
func ( *dotWriter) () error {
if .w.dot == {
.w.dot = nil
}
:= .w.W
switch .state {
default:
.WriteByte('\r')
fallthrough
case wstateCR:
.WriteByte('\n')
fallthrough
case wstateBeginLine:
.Write(dotcrnl)
}
return .Flush()
![]() |
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. |