Help us shape the future of Go! Take the 2026 Go Developer Survey

kv3

package
v0.1.9 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 23, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package kv3 reads binary KeyValues3 versions 4 and 5 and writes version 5, the format Source 2 compiled resources store their data in.

Decode accepts untrusted input: malformed data returns an error and never panics, and a value budget bounds the work one buffer can demand.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Decode

func Decode(data []byte) (any, error)

Decode reads binary KeyValues3 data. Objects decode as map[string]any and arrays as []any; the scalars as nil, bool, int64, uint64, float64, string and Blob. Flags are dropped.

func Encode

func Encode(value any) ([]byte, error)

Encode writes value as binary KeyValues3 version 5 with LZ4 compression, the form the resource compiler writes. It takes nil, bool, every integer type, float32, float64, string, []any, Object and map[string]any. An integer is written in the narrowest of int32, uint32, int64 and uint64 that holds it.

Types

type Blob

type Blob int

Blob is a binary blob's size in bytes; the reader skips its payload.

type Member

type Member struct {
	// Key names the member.
	Key string
	// Value is the member's value.
	Value any
}

Member is one key and value of an Object.

type Object

type Object []Member

Object is a KeyValues3 object whose members keep their order. Encode also takes a map[string]any, whose members it writes in key order.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL