Skip to content

tinywasm/binary

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

79 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Binary

Project Badges

Binary is a high-performance binary serialization library for Go, specifically designed for TinyGo compatibility and resource-constrained environments.

Features

  • TinyGo Compatible: Optimized for embedded systems and WebAssembly.
  • Extreme Performance: Minimal allocations and efficient encoding.
  • Simple API: Just Encode and Decode.
  • Zero Dependencies: Core logic is lightweight and self-contained.

Installation

go get github.com/tinywasm/binary

Quick Start

package main

import (
    "fmt"
    "github.com/tinywasm/binary"
)

type User struct {
    Name string
    Age  int
}

func main() {
    user := &User{Name: "Alice", Age: 30}

    // Encode
    var data []byte
    binary.Encode(user, &data)

    // Decode
    var decoded User
    binary.Decode(data, &decoded)

    fmt.Printf("Decoded: %+v\n", decoded)
}

API

  • Encode(input, output any) error: Encodes into *[]byte or io.Writer.
  • Decode(input, output any) error: Decodes from []byte or io.Reader.
  • SetLog(fn func(...any)): Sets internal logger for debugging.

License MIT

This project is an adaptation of Kelindar/binary focused on TinyGo.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Sponsor this project

 

Packages

No packages published

Contributors 2

  •  
  •  

Languages