Categorygithub.com/miratronix/lingo
modulepackage
0.0.0-20240323220928-da3f47375526
Repository: https://github.com/miratronix/lingo.git
Documentation: pkg.go.dev

# README

lingo

A basic collection of encoding/decoding packages and tools.

Usage

Lingo ships with three encodings, all of which use the standard json struct tag:

  • JSON:
import "github.com/miratronix/lingo"
e := lingo.JSON

// Encode a structure as bytes, using the 'json' struct tag
bytes, err := e.Encode(someStructure)

// Decode bytes into a structure, using the 'json' struct tag
err := e.Decode(bytes, &someStructure)
  • Message Pack:
import "github.com/miratronix/lingo"
e := lingo.MessagePack

// Encode a structure as bytes, using the 'json' struct tag
bytes, err := e.Encode(someStructure)

// Decode bytes into a structure, using the 'json' struct tag
err := e.Decode(bytes, &someStructure)
  • Map:
import "github.com/miratronix/lingo"
e := lingo.Map

// Encode a structure into a map, using the 'json' struct tag
mapped := e.Encode(&someStructure)

// Decode a map into a structure, using the 'json' struct tag
err := e.Decode(someMap, &someStructure)

# Variables

JSON exposes a pre-built JSON encoding.
Map exposes a pre-built map encoding.
MessagePack exposes a pre-built message pack encoding.

# Interfaces

Encoding defines an encoder/decoder interface.