Help improve this documentation
This documentation is still new and evolving. If you spot any mistakes, unclear explanations, or missing details, please open an issue.
Your feedback helps us improve!
Encoding/Base64 operatorsโ
This page lists all operators available in the encoding/base64 sub-package of ro.
Installโ
First, import the sub-package in your project:
go get -u github.com/samber/ro/plugins/encoding/base64
Encodeโ
Encodes input into a base64 string.
import (
"encoding/base64"
"github.com/samber/ro"
robase64 "github.com/samber/ro/plugins/encoding/base64"
)
obs := ro.Pipe[[]byte, string](
ro.Just([]byte("hello world")),
robase64.Encode[[]byte](base64.StdEncoding),
)
sub := obs.Subscribe(ro.PrintObserver[string]())
defer sub.Unsubscribe()
// Next: aGVsbG8gd29ybGQ=
// CompletedSimilar:Prototype:func Encode[T ~[]byte](encoder *base64.Encoding)Decodeโ
Decodes input from a base64 string.
import (
"encoding/base64"
"github.com/samber/ro"
robase64 "github.com/samber/ro/plugins/encoding/base64"
)
obs := ro.Pipe[string, []byte](
ro.Just("aGVsbG8gd29ybGQ="),
robase64.Decode[string](base64.StdEncoding),
)
sub := obs.Subscribe(ro.PrintObserver[[]byte]())
defer sub.Unsubscribe()
// Next: [104 101 108 108 111 32 119 111 114 108 100]
// CompletedSimilar:Prototype:func Decode[T ~string](encoder *base64.Encoding)