Source File
w_b64.go
Belonging Package
github.com/go-faster/jx
package jx
import (
stdbase64
)
// Base64 encodes data as standard base64 encoded string.
//
// Same as encoding/json, base64.StdEncoding or RFC 4648.
func ( *Writer) ( []byte) bool {
if == nil {
return .Null()
}
if .byte('"') {
return true
}
:= base64.StdEncoding.EncodedLen(len())
switch {
case .stream == nil || len(.Buf)+ <= cap(.Buf):
:= len(.Buf)
.Buf = append(.Buf, make([]byte, )...)
base64.StdEncoding.Encode(.Buf[:], )
default:
:= .stream
var bool
.Buf, = .flush(.Buf)
if {
return true
}
:= stdbase64.NewEncoder(stdbase64.StdEncoding, .writer)
if , := .Write(); != nil {
.setError()
return true
}
if := .Close(); != nil {
.setError()
return true
}
}
return .byte('"')
}
The pages are generated with Golds v0.6.7. (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 @Go100and1 (reachable from the left QR code) to get the latest news of Golds. |