• Unfortunately, we have experienced significant hard drive damage that requires urgent maintenance and rebuilding. The forum will be a state of read only until we install our new drives and rebuild all the configurations needed. Please follow our Facebook page for updates, we will be back up shortly! (The forum could go offline at any given time due to the nature of the failed drives whilst awaiting the upgrades.) When you see an Incapsula error, you know we are in the process of migration.

[DEV] go-wz - Golang WZ library

Everything is possible~
Loyal Member
Joined
Jan 9, 2008
Messages
818
Reaction score
847
This is a golang WZ library. It only supports reading (for now).
You need to use casting to deserialize objects.

Sourcecode is here:

Basically, run go get -d github.com/diamondo25/go-wz to download the library. Then, import the library using import "github.com/diamondo25/go-wz" in your sourcecode.

Because of the use of multithreading and workpooling, it is able to load all data of Data.wz (v.3) in 4 seconds (tested on an Macbook Pro w/ i7, 16 GB RAM and 500GB SSD). You can also disable this system and use lazyloading instead (set LazyLoading of the WZFile to false).

Todo:

Example:

Code:
package main

import (
	"bufio"
	"flag"
	"fmt"
	"github.com/diamondo25/go-wz"
	"os"
)

func main() {
	base, err := wz.NewFile("Data.wz")
	if err != nil {
		panic(err)
	}
	// base.Debug = true
	flag.BoolVar(&base.Debug, "debug", false, "Toggles debugging mode")
	flag.BoolVar(&base.LazyLoading, "lazyloading", true, "If disabled, all data will be loaded in memory")
	flag.Parse()

	fmt.Println("Loading ", base.Filename)
	base.Parse()

	base.WaitUntilLoaded()

	fmt.Println("Loaded!")

	fmt.Println("Smap: ", base.GetFromPath("smap.img"))
	fmt.Println("Falling tomb thing z value: ", base.GetFromPath("Effect/Tomb.img/fall/0/z"))
	fmt.Println("Falling tomb thing origin X: ", base.GetFromPath("Effect/Tomb.img/fall/0/origin/X"))

	reader := bufio.NewReader(os.Stdin)
	reader.ReadString('\n')

	fmt.Println("Shutting Down")
}
 
Back
Top