index01d / demoinfocs-golang

High performance CS:GO demo parser for Go (demoinfo)

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

demoinfocs-golang - A CS:GO Demo Parser

Is a Go library for super fast parsing and analysing of Counter Strike: Global Offensive (CS:GO) demos (aka replays). It is based on Valve's demoinfogo and SatsHelix's demoinfo.

GoDoc Build Status codecov Go Report License FOSSA Status

Discussions / Chat

You can use gitter to ask questions and discuss ideas about this project.

Gitter chat


This library is intended to be used with go 1.11 or higher as it is built using Go modules.

It's recommended to use modules for consumers as well if possible. If you are unfamiliar with Go modules there's a list of recommended resources in the wiki.

Go Get

go get -u

If you are using a older (v0.x) version of the library, check out the v0.5 branch. However, it's highly recommended to switch to master (v1.0.0), which contains many new features and improvements. It also promises compatibility with new relases for the foreseeable future.


This is a simple example on how to handle game events using this library. It prints all kills in a given demo (killer, weapon, victim, was it a wallbang/headshot?) by registering a handler for events.Kill.

Check out the godoc of the events package for some information about the other available events and their purpose.

package main

import (

	dem ""
	events ""

// Run like this: go run print_kills.go
func main() {
	f, err := os.Open("/path/to/demo.dem")
	if err != nil {
	defer f.Close()

	p := dem.NewParser(f)

	// Register handler on kill events
	p.RegisterEventHandler(func(e events.Kill) {
		var hs string
		if e.IsHeadshot {
			hs = " (HS)"
		var wallBang string
		if e.PenetratedObjects > 0 {
			wallBang = " (WB)"
		fmt.Printf("%s <%v%s%s> %s\n", e.Killer.Name, e.Weapon.Weapon, hs, wallBang, e.Victim.Name)

	// Parse to end
	err = p.ParseToEnd()
	if err != nil {

Sample output

Running the code above will print something like this:

xms <AK-47 (HS)> crisby
tiziaN <USP-S (HS)> Ex6TenZ
tiziaN <USP-S> mistou
tiziaN <USP-S (HS)> ALEX
xms <Glock-18 (HS)> tiziaN
keev <AWP (HS) (WB)> to1nou

More examples

Check out the examples folder for more examples, like how to generate heatmaps like this one:

sample heatmap


  1. Only for some demos; in MM demos the chat is encrypted for example.

Performance / Benchmarks

Two of the top priorities of this parser are performance and concurrency.

Here are some benchmark results from a system with a Intel i7 2600k CPU and SSD disk running Windows 10 and a demo with 85'000 frames.


Benchmark Description Average Duration Speed
BenchmarkConcurrent Read and parse 8 demos concurrently 2.84 s (per 8 demos) ~240'000 ticks / s
BenchmarkDemoInfoCs Read demo from drive and parse 1.24 s ~68'000 ticks / s
BenchmarkInMemory Read demo from memory and parse 1.21 s ~70'000 ticks / s

That's about 1h of gameplay per second when parsing in parallel (recorded at 64 ticks per second) - or 18 minues per second when only parsing a single demo at a time.

Raw output

$ go test -run _NONE_ -bench . -benchtime 30s -benchmem -concurrentdemos 8
goos: windows
goarch: amd64
BenchmarkDemoInfoCs-8             30    1237133300 ns/op    256055133 B/op    879104 allocs/op
BenchmarkInMemory-8               30    1216333013 ns/op    255900492 B/op    878900 allocs/op
BenchmarkConcurrent-8             20    2840799900 ns/op    2046866843 B/op  7031208 allocs/op
--- BENCH: BenchmarkConcurrent-8
    demoinfocs_test.go:369: Running concurrency benchmark with 8 demos
    demoinfocs_test.go:369: Running concurrency benchmark with 8 demos
    demoinfocs_test.go:369: Running concurrency benchmark with 8 demos
ok  165.244s


We use SemVer for versioning. For the versions available, see the tags on this repository. There is one caveat however: Beta features - which are marked as such via comments and in release notes - may change in minor releases.

It's recommended to use some kind of dependency management system such as dep to ensure reproducible builds.

Projects using demoinfocs-golang

  • - A suite of explorative tools to help you analyze and improve your CS:GO performance.

If your project is using this library feel free to submit a PR or send a message in Gitter to be included in the list.


Running tests

To run tests Git LFS is required.

git submodule init
git submodule update
pushd cs-demos && git lfs pull -I '*' && popd
go test

Here's a cool gist of a pre-commit hook to run tests before each commit. You can put this inside the .git/hooks directory to avoid committing/pushing code with build errors or failing tests.


You can use the build tag debugdemoinfocs (i.e. go test -tags debugdemoinfocs -v) to print out debugging information - such as game events or unhandled demo-messages - during the parsing process.
Side-note: The tag isn't called debug to avoid naming conflicts with other libs (and underscores in tags don't work, apparently).

To change the default debugging behavior, Go's ldflags parameter can be used. Example for additionally printing out all server-classes with their properties: -ldflags '-X'

Check out debug_on.go for any other settings that can be changed.

Generating protobuf code

Should you need to re-generate the protobuf generated code in the msg package, you will need the following tools:

Make sure both are inside your PATH variable.

After installing these use go generate ./msg to generate the protobuf code.


This project is licensed under the MIT license.

FOSSA Status

ezoic increase your site revenue


High performance CS:GO demo parser for Go (demoinfo)

License:MIT License


Language:Go 99.6%Language:Shell 0.4%