Documentation
¶
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Codec ¶
type Codec struct{}
Codec is a Codec[[]byte] backed by encoding/base64. It is safe for concurrent use.
Example ¶
package main
import (
"fmt"
"github.com/foomo/goencode/base64"
)
func main() {
c := base64.NewCodec()
encoded, err := c.Encode([]byte("hello"))
if err != nil {
fmt.Printf("Encode failed: %v\n", err)
return
}
fmt.Printf("Encoded: %s\n", string(encoded))
}
Output: Encoded: aGVsbG8=
type StreamCodec ¶
type StreamCodec struct{}
StreamCodec is a StreamCodec[[]byte] backed by encoding/base64. It is safe for concurrent use.
Example ¶
package main
import (
"bytes"
"fmt"
"github.com/foomo/goencode/base64"
)
func main() {
c := base64.NewStreamCodec()
var buf bytes.Buffer
if err := c.Encode(&buf, []byte("hello")); err != nil {
fmt.Printf("Encode failed: %v\n", err)
return
}
fmt.Printf("Encoded: %s\n", buf.String())
var decoded []byte
if err := c.Decode(&buf, &decoded); err != nil {
fmt.Printf("Decode failed: %v\n", err)
return
}
fmt.Printf("Decoded: %s\n", string(decoded))
}
Output: Encoded: aGVsbG8= Decoded: hello
func NewStreamCodec ¶
func NewStreamCodec() StreamCodec
NewStreamCodec returns a Base64 stream serializer.
Click to show internal directories.
Click to hide internal directories.