/go-osr

An osu! replay parser for Golang

Primary LanguageGoMIT LicenseMIT

go-osr

An osu! replay parser for Golang inspired by node-osr

Installation

go get github.com/robloxxa/go-osr

Documentation

Examples

Read replay from file

package main

import (
	"fmt"
	"github.com/robloxxa/go-osr"
)

func main() {
	r, err := goosr.NewReplayFromFile("replay.osr")
	if err != nil {
		panic(err)
	}
	fmt.Println(r)
}

or

package main

import (
	"fmt"
	"github.com/robloxxa/go-osr"
)

func main() {
	r := goosr.NewReplay()
	data := []byte{} // Some data in binary
	err := r.Unmarshal(data)
	if err != nil {
		panic(err)
	}
	fmt.Println(r)
}

Write replay data to file

package main

import (
	"fmt"
	"github.com/robloxxa/go-osr"
)

func main() {
	r, err := goosr.NewReplayFromFile("replay.osr")
	if err != nil {
		panic(err)
	}
	r.CountMiss = 1 // Change some data from parsed replay
	err = r.WriteToFile("replay.osr")
	if err != nil {
		panic(err)
	}
}

or

package main

import (
	"github.com/robloxxa/go-osr"
	"io/fs"
	"os"
)

func main() {
	r, err := goosr.NewReplayFromFile("replay.osr")
	if err != nil {
		panic(err)
	}
	r.CountMiss = 1 // Change some data from parsed replay
	b, err := r.Marshal()
	if err != nil {
		panic(err)
	}
	err = os.WriteFile("replay.osr", b, fs.ModePerm)
	if err != nil {
		panic(err)
	}
}