Giter Site home page Giter Site logo

goetf's Introduction

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

package main

import (
	"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

package main

import (
	"fmt"

	"github.com/nicolito128/goetf"
)

func main() {
	var out int

    bin := []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

References

goetf's People

Contributors

nicolito128 avatar

Stargazers

 avatar  avatar Clayton Kehoe avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.