/ljpack

[WIP] LuaJIT string.buffer serializer/deserializer in golang

Primary LanguageGoBSD 2-Clause "Simplified" LicenseBSD-2-Clause

LuaJIT string.buffer encoding for Golang

Build Status PkgGoDev

Resources

Notes

The encoding format for LuaJIT string.buffer is not a formalized structure, the format could change at any time. Thus use this project with your own risk.

Supported:

  • nil, false, true, userdata NULL
  • int (int32), double (float64)
  • Empty table, hash, 0-based array, 1-based array
  • FFI int64, uint64, complex
  • string, interned string

Work in Progress:

  • lightud32, lightud64
  • Mixed table, Metatable dict entry

Not supported

  • Non-string value as hash keys

Features

Installation

ljpack supports 2 last Go versions and requires support for Go modules. So make sure to initialize a Go module:

go mod init github.com/my/repo

And then install ljpack:

go get github.com/fffonion/ljpack

Quickstart

import "github.com/fffonion/ljpack"

func ExampleMarshal() {
    type Item struct {
        Foo string
    }

    b, err := ljpack.Marshal(&Item{Foo: "bar"})
    if err != nil {
        panic(err)
    }

    var item Item
    err = ljpack.Unmarshal(b, &item)
    if err != nil {
        panic(err)
    }
    fmt.Println(item.Foo)
    // Output: bar
}

Credits