https://github.com/manifoldco/go-base64
A raw base64 url encoding library for JSON
https://github.com/manifoldco/go-base64
base64 go golang json
Last synced: 3 months ago
JSON representation
A raw base64 url encoding library for JSON
- Host: GitHub
- URL: https://github.com/manifoldco/go-base64
- Owner: manifoldco
- License: bsd-3-clause
- Created: 2017-04-03T16:04:14.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2020-01-13T14:58:54.000Z (over 5 years ago)
- Last Synced: 2025-05-08T08:03:23.801Z (5 months ago)
- Topics: base64, go, golang, json
- Language: Go
- Homepage: https://www.manifold.co
- Size: 14.6 KB
- Stars: 3
- Watchers: 25
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Contributing: .github/CONTRIBUTING.md
- License: LICENSE.md
Awesome Lists containing this project
README
# go-base64
A raw base64 URL encoding library for JSON.
[Code of Conduct](./.github/CONDUCT.md) |
[Contribution Guidelines](./.github/CONTRIBUTING.md)[](https://github.com/manifoldco/go-base64/releases)
[](https://godoc.org/github.com/manifoldco/go-base64)
[](https://travis-ci.org/manifoldco/go-base64)
[](https://goreportcard.com/report/github.com/manifoldco/go-base64)
[](./LICENSE.md)## Usage
`base64` Provides a convenient way to read and write raw (no padding) base64 URL
values.```go
package mainimport (
"encoding/json"
"fmt""github.com/manifoldco/go-base64"
)type Example struct {
Name string `json:"name"`
Data *base64.Value `json:"data"`
RegularData []byte `json:"regular"`
}func main() {
sample := []byte{0xF, 0xEE, 0xD, 0xC, 0x0D}
e := &Example{
Name: "test data",
Data: base64.New(sample),
RegularData: sample,
}o, _ := json.MarshalIndent(e, "", " ")
fmt.Println(string(o))
}
```Outputs:
```
{
"name": "test data",
"data": "D-4NDA0",
"regular": "D+4NDA0="
}
```