Byte - Plugin operators
This page lists all operators available in the bytes sub-package of ro.
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!
Installโ
First, import the sub-package in your project:
go get -u github.com/samber/ro/plugins/bytes
CamelCaseโ
Converts the string to camel case.
import ("github.com/samber/ro"robytes "github.com/samber/ro/plugins/bytes")obs := ro.Pipe[[]byte, []byte](ro.Just([]byte("hello_world_world")),robytes.CamelCase[[]byte](),)sub := obs.Subscribe(ro.PrintObserver[[]byte]())defer sub.Unsubscribe()// Next: [104 101 108 108 111 87 111 114 108 100 87 111 114 108 100]// CompletedCamelCaseWithLanguage
Converts the string to camel case using locale-aware casing.
import ("github.com/samber/ro"robytes "github.com/samber/ro/plugins/bytes""golang.org/x/text/language")obs := ro.Pipe[[]byte, []byte](ro.Just([]byte("Istanbul city")),robytes.CamelCaseWithLanguage[[]byte](language.Turkish),)sub := obs.Subscribe(ro.PrintObserver[[]byte]())defer sub.Unsubscribe()// Next: [196 177 115 116 97 110 98 117 108 67 105 116 121]// CompletedVariant:Similar:Prototypes:func CamelCase[T ~[]byte]()func CamelCaseWithLanguage[T ~[]byte](tag language.Tag)KebabCaseโ
Converts the string to kebab case.
import ("github.com/samber/ro"robytes "github.com/samber/ro/plugins/bytes")obs := ro.Pipe[[]byte, []byte](ro.Just([]byte("HelloWorldWorld")),robytes.KebabCase[[]byte](),)sub := obs.Subscribe(ro.PrintObserver[[]byte]())defer sub.Unsubscribe()// Next: [104 101 108 108 111 45 119 111 114 108 100 45 119 111 114 108 100]// CompletedKebabCaseWithLanguage
Converts the string to kebab case using locale-aware casing.
import ("github.com/samber/ro"robytes "github.com/samber/ro/plugins/bytes""golang.org/x/text/language")obs := ro.Pipe[[]byte, []byte](ro.Just([]byte("IstanbulCity")),robytes.KebabCaseWithLanguage[[]byte](language.Turkish),)sub := obs.Subscribe(ro.PrintObserver[[]byte]())defer sub.Unsubscribe()// Next: [196 177 115 116 97 110 98 117 108 45 99 105 116 121]// CompletedVariant:Prototypes:func KebabCase[T ~[]byte]()func KebabCaseWithLanguage[T ~[]byte](tag language.Tag)Capitalizeโ
Capitalizes the first letter of the string.
import ("github.com/samber/ro"robytes "github.com/samber/ro/plugins/bytes")obs := ro.Pipe[[]byte, []byte](ro.Just([]byte("hello world")),robytes.Capitalize[[]byte](),)sub := obs.Subscribe(ro.PrintObserver[[]byte]())defer sub.Unsubscribe()// Next: [72 101 108 108 111 32 119 111 114 108 100]// CompletedCapitalizeWithLanguage
Capitalizes the first letter using locale-aware casing.
import ("github.com/samber/ro"robytes "github.com/samber/ro/plugins/bytes""golang.org/x/text/language")obs := ro.Pipe[[]byte, []byte](ro.Just([]byte("istanbul")),robytes.CapitalizeWithLanguage[[]byte](language.Turkish),)sub := obs.Subscribe(ro.PrintObserver[[]byte]())defer sub.Unsubscribe()// Next: [196 176 115 116 97 110 98 117 108]// CompletedVariant:Similar:Prototypes:func Capitalize[T ~[]byte]()func CapitalizeWithLanguage[T ~[]byte](tag language.Tag)Ellipsisโ
Truncates the string to specified length and appends "..." if longer.
import ("github.com/samber/ro"robytes "github.com/samber/ro/plugins/bytes")obs := ro.Pipe[[]byte, []byte](ro.Just([]byte("This is a very long string")),robytes.Ellipsis[[]byte](10),)sub := obs.Subscribe(ro.PrintObserver[[]byte]())defer sub.Unsubscribe()// Next: [84 104 105 115 32 105 115 32 46 46 46]// CompletedSimilar:Prototype:func Ellipsis[T ~[]byte](length int)PascalCaseโ
Converts the string to pascal case.
import ("github.com/samber/ro"robytes "github.com/samber/ro/plugins/bytes")obs := ro.Pipe[[]byte, []byte](ro.Just([]byte("hello_world_world")),robytes.PascalCase[[]byte](),)sub := obs.Subscribe(ro.PrintObserver[[]byte]())defer sub.Unsubscribe()// Next: [72 101 108 108 111 87 111 114 108 100 87 111 114 108 100]// CompletedPascalCaseWithLanguage
Converts the string to pascal case using locale-aware casing.
import ("github.com/samber/ro"robytes "github.com/samber/ro/plugins/bytes""golang.org/x/text/language")obs := ro.Pipe[[]byte, []byte](ro.Just([]byte("istanbul city")),robytes.PascalCaseWithLanguage[[]byte](language.Turkish),)sub := obs.Subscribe(ro.PrintObserver[[]byte]())defer sub.Unsubscribe()// Next: [196 176 115 116 97 110 98 117 108 67 105 116 121]// CompletedVariant:Similar:Prototypes:func PascalCase[T ~[]byte]()func PascalCaseWithLanguage[T ~[]byte](tag language.Tag)Randomโ
Generates a random string of specified size using charset.
import ("github.com/samber/ro"robytes "github.com/samber/ro/plugins/bytes")obs := ro.Pipe[int, []byte](ro.Just(1, 2, 3),robytes.Random[int](10, []rune("abcdefghijklmnopqrstuvwxyz")),)sub := obs.Subscribe(ro.PrintObserver[[]byte]())defer sub.Unsubscribe()// Next: [some random bytes]// Next: [some random bytes]// Next: [some random bytes]// CompletedSimilar:Prototype:func Random[T any](size int, charset []rune)SnakeCaseโ
Converts the string to snake case.
import ("github.com/samber/ro"robytes "github.com/samber/ro/plugins/bytes")obs := ro.Pipe[[]byte, []byte](ro.Just([]byte("HelloWorldWorld")),robytes.SnakeCase[[]byte](),)sub := obs.Subscribe(ro.PrintObserver[[]byte]())defer sub.Unsubscribe()// Next: [104 101 108 108 111 95 119 111 114 108 100 95 119 111 114 108 100]// CompletedSnakeCaseWithLanguage
Converts the string to snake case using locale-aware casing.
import ("github.com/samber/ro"robytes "github.com/samber/ro/plugins/bytes""golang.org/x/text/language")obs := ro.Pipe[[]byte, []byte](ro.Just([]byte("IstanbulCity")),robytes.SnakeCaseWithLanguage[[]byte](language.Turkish),)sub := obs.Subscribe(ro.PrintObserver[[]byte]())defer sub.Unsubscribe()// Next: [196 177 115 116 97 110 98 117 108 95 99 105 116 121]// CompletedVariant:Similar:Prototypes:func SnakeCase[T ~[]byte]()func SnakeCaseWithLanguage[T ~[]byte](tag language.Tag)Wordsโ
Splits the string into words.
import ("github.com/samber/ro"robytes "github.com/samber/ro/plugins/bytes")obs := ro.Pipe[[]byte, []byte](ro.Just([]byte("hello world from go")),robytes.Words[[]byte](),)sub := obs.Subscribe(ro.PrintObserver[[][]byte]())defer sub.Unsubscribe()// Next: [[104 101 108 108 111] [119 111 114 108 100] [102 114 111 109] [103 111]]// CompletedSimilar:Prototype:func Words[T ~[]byte]()