Source File
formatter.go
Belonging Package
github.com/gookit/goutil/comdef
package comdefimport ()// DataFormatter interfacetype DataFormatter interface {Format() stringFormatTo(w io.Writer)}// BaseFormatter struct//// Usage://// type YourFormatter struct {// comdef.BaseFormatter// }// // implement the DataFormatter interface...type BaseFormatter struct {ow ByteStringWriter// Out formatted to the writerOut io.Writer// Src data(array, map, struct) for formatSrc any// MaxDepth limit depth for array, map data TODOMaxDepth int// Prefix string for each elementPrefix string// Indent string for format each elementIndent string// ClosePrefix string for last "]", "}"ClosePrefix string}// Reset after formatfunc ( *BaseFormatter) () {.Out = nil.Src = nil}// SetOutput writerfunc ( *BaseFormatter) ( io.Writer) {.Out =}// BsWriter warp the Out, build a ByteStringWriterfunc ( *BaseFormatter) () ByteStringWriter {if .ow == nil {if .Out == nil {.ow = new(bytes.Buffer)} else if , := .Out.(ByteStringWriter); {.ow =} else {.ow = stdio.NewWriteWrapper(.Out)}}return .ow}
![]() |
The pages are generated with Golds v0.8.4. (GOOS=linux 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 @zigo_101 (reachable from the left QR code) to get the latest news of Golds. |