Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/nicolito128/goetf
Go encoding module for ETF (External Term Format).
https://github.com/nicolito128/goetf
encoding-decoding erlang etf go golang
Last synced: 3 months ago
JSON representation
Go encoding module for ETF (External Term Format).
- Host: GitHub
- URL: https://github.com/nicolito128/goetf
- Owner: nicolito128
- License: mit
- Created: 2024-07-30T06:54:31.000Z (5 months ago)
- Default Branch: main
- Last Pushed: 2024-08-13T03:44:45.000Z (5 months ago)
- Last Synced: 2024-09-30T03:41:34.868Z (3 months ago)
- Topics: encoding-decoding, erlang, etf, go, golang
- Language: Go
- Homepage:
- Size: 115 KB
- Stars: 4
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# GoETF
> [!WARNING]
> The module is not yet at version `1.0.0` so it's not possible to ensure that there will be no breaking changes.Go encoding module for ETF (External Term Format).
## Why GoETF?
The external term format is mainly used in Erlang's distribution system. Occasionally, it's necessary to encode and decode this particular binary format for communication between different APIs. This format offers the advantage of being faster and more lightweight compared to traditional JSON.## Getting started
### Requirements
* `go v1.22+`
### Installation
go get -u github.com/nicolito128/goetf
### Encoding example
```go
package mainimport (
"fmt""github.com/nicolito128/goetf"
)func main() {
phrase := "Hello, world!"data, err := goetf.Marshal(phrase)
if err != nil {
panic(err)
}fmt.Println("Encoded:", data)
}
```### Decoding example
```go
package mainimport (
"fmt""github.com/nicolito128/goetf"
)func main() {
var out intbin := []byte{131, 98, 0, 0, 1, 1}
if err := goetf.Unmarshal(bin, &out); err != nil {
panic(err)
}fmt.Println("Out:", out)
}
```For both examples, use the `go run` command, like:
go run example_file.go
### Examples
* Visit the [examples folder](./examples) for more sample codes.
## References
* [Erlang Runtime System Application (ERTS) - External Term Format](https://www.erlang.org/doc/apps/erts/erl_ext_dist.html)