A Lexer and Parser for Valves Data Format (known as vdf) written in Go.
- Table of Contents
- Installation
- Usage
- API-Documentation
- Development
- Press
- VDF parser in other languages
- Inspiration
- License
It is go gettable
$ go get github.com/andygrunwald/vdf
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
[...]
]
]
The official Go package documentation can be found at https://pkg.go.dev/github.com/andygrunwald/vdf.
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
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
- 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
The code is inspired by @benbjohnson's article Handwritten Parsers & Lexers in Go and his example sql-parser. Thank you Ben!
This project is released under the terms of the MIT license.