Go implementation of the Twilic wire format and session-aware encoder/decoder.
This module's default Encode / Decode API targets Twilic v2.
- Dynamic encoding/decoding (
Encode,Decode) - Schema-aware encoding (
EncodeWithSchema) - Batch and micro-batch encoding (
EncodeBatch,SessionEncoder.EncodeMicroBatch) - Stateful features (base snapshots, state patch, template batch, control stream, trained dictionary)
twilic-go/
export.go, version.go # public import path (github.com/twilic/twilic-go)
internal/core/ # wire, model, codec, session, protocol, v2, tests
scripts/ # Rust interop fixtures and smoke checks
docs/
The repository root stays thin: import github.com/twilic/twilic-go only. Implementation details live under internal/core/, similar to src/ in the Zig crate.
- Go 1.22 or later
go get github.com/twilic/twilic-gopackage main
import (
"fmt"
twilic "github.com/twilic/twilic-go"
)
func main() {
value := twilic.NewMap(
twilic.Entry("id", twilic.NewU64(1001)),
twilic.Entry("name", twilic.NewString("alice")),
)
bytes, err := twilic.Encode(value)
if err != nil {
panic(err)
}
decoded, err := twilic.Decode(bytes)
if err != nil {
panic(err)
}
fmt.Println(twilic.Equal(decoded, value))
}package main
import (
twilic "github.com/twilic/twilic-go"
)
func main() {
enc := twilic.NewSessionEncoder(twilic.DefaultSessionOptions())
value := twilic.NewMap(
twilic.Entry("id", twilic.NewU64(1)),
twilic.Entry("role", twilic.NewString("admin")),
)
if _, err := enc.Encode(&value); err != nil {
panic(err)
}
}Run checks locally:
gofmt -l .
go vet ./...
go test ./...Rust client interop smoke check (Go server -> Rust client):
bash scripts/check-rust-client-interop.shGo client interop smoke check (Rust server -> Go client):
bash scripts/check-go-client-interop.shRun both directions:
bash scripts/check-interop.shNote: these scripts expect ../twilic-rust to exist as a sibling directory.
Documentation is formatted and linted with Prettier and markdownlint (see docs/CONTRIBUTING.md).
- CI workflow:
.github/workflows/ci.yml - Interop workflow:
.github/workflows/interop.yml - Release workflow:
.github/workflows/publish-module.yml(tagv*must matchversion.go)
This module mirrors the Twilic wire format spec at twilic/twilic and stays in lockstep with the Rust and Zig reference implementations.
See docs/SPEC-TEST-TRACEABILITY.md for the spec-section to test mapping.
This project is licensed under the MIT License - see the LICENSE file for details.