Vdf
A Lexer and Parser for Valves Data Format (known as vdf) written in Go
Install / Use
/learn @andygrunwald/VdfREADME
vdf: A Lexer and Parser for Valves Data Format (known as vdf)
A Lexer and Parser for Valves Data Format (known as vdf) written in Go.
Table of Contents
- Table of Contents
- Installation
- Usage
- API-Documentation
- Development
- Press
- VDF parser in other languages
- Inspiration
- License
Installation
It is go gettable
$ go get github.com/andygrunwald/vdf
Usage
Given a file named gamestate_integration_consolesample.cfg with content:
"Console Sample v.1"
{
"uri" "http://127.0.0.1:3000"
"timeout" "5.0"
"buffer" "0.1"
"throttle" "0.5"
"heartbeat" "60.0"
[...]
}
Can be parsed with this Go code:
package main
import (
"fmt"
"os"
"github.com/andygrunwald/vdf"
)
func main() {
f, err := os.Open("gamestate_integration_consolesample.cfg")
if err != nil {
panic(err)
}
p := vdf.NewParser(f)
m, err := p.Parse()
if err != nil {
panic(err)
}
fmt.Println(m)
}
And it will output:
map[
Console Sample v.1:map[
uri:http://127.0.0.1:3000
timeout:5.0
buffer:0.1
throttle:0.5
heartbeat:60.0
[...]
]
]
API-Documentation
The official Go package documentation can be found at https://pkg.go.dev/github.com/andygrunwald/vdf.
Development
Unit testing
To run the local unit tests, execute
$ make test
To run the local unit tests and view the unit test code coverage in your local web browser, execute
$ make test-coverage-html
Fuzzing tests
This library implements Go fuzzing. The generated fuzzing corpus is stored in andygrunwald/vdf-fuzzing-corpus, to avoid blowing up the size of this repository.
To run fuzzing locally, execute
$ make init-fuzzing # Clone the corpus into testdata/fuzz
$ make clean-fuzzing # Clean the local fuzzing cache
$ make test-fuzzing # Execute the fuzzing
Press
VDF parser in other languages
- PHP and JavaScript: rossengeorgiev/vdf-parser
- PHP: devinwl/keyvalues-php
- PHP: lukezbihlyj/vdf-parser
- PHP: EXayer/vdf-converter
- C#: sanmadjack/VDF
- C#: shravan2x/Gameloop.Vdf
- C#: Indieteur/Steam-Apps-Management-API
- C#: GerhardvanZyl/Steam-VDF-Converter
- C++: TinyTinni/ValveFileVDF
- Java: DHager/hl2parse
- JavaScript node-steam/vdf
- JavaScript: Corecii/steam-binary-vdf-ts
- JavaScript: RoyalBingBong/vdfplus
- JavaScript: key-values/key-values-ts
- Python: ValvePython/vdf
- Python: gorgitko/valve-keyvalues-python
- Python: noriah/PyVDF
- Go: marshauf/keyvalues
- Go: Jleagle/steam-go
- Go: Wakeful-Cloud/vdf
- Rust: LovecraftianHorror/vdf-rs
- Rust: Corecii/steam_vdf
- Other (VS-Code Extension): cooolbros/vscode-vdf
- And some more: Github search for vdf valve
Inspiration
The code is inspired by @benbjohnson's article Handwritten Parsers & Lexers in Go and his example sql-parser. Thank you Ben!
License
This project is released under the terms of the MIT license.
Related Skills
node-connect
350.1kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
109.9kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
350.1kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
qqbot-media
350.1kQQBot 富媒体收发能力。使用 <qqmedia> 标签,系统根据文件扩展名自动识别类型(图片/语音/视频/文件)。
