Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I often find myself wanting to output bytes as base64 instead of hex because base64 is more compact, and the
base64
cli command is easier to use thanxxd
. Having to write.Str("foo", base64.StdEncoding.EncodeToString(data))
isn't very nice though and it's not as efficient as encoding directly into the buffer.This PR adds
.Base64
and.Base64Custom
helper methods. The former just takes bytes and appends with standard padded base64, while the latter additionally takes abase64.Encoding
instance to allow all the other kinds (urlsafe and/or unpadded base64). I'm not completely sure if the Custom method is a good idea, so I can change that if needed. It might make sense to have an url-safe method instead, or just not have any other options than standard.