asar-go
This Go package enables reading, writing, and modifying ASAR files.
It includes a comprehensive test suite with test files from the official repository.
The code is 100% human-written.
Examples
Extract a archive
package main
import (
"fmt"
"os"
"codeberg.org/JakobDev/asar-go"
)
func main() {
archive, err := asar.OpenFile("path", &asar.ReadOptions{})
if err != nil {
fmt.Println(err)
os.Exit(1)
}
defer archive.Close()
err = archive.ExtractAll("extract_path")
if err != nil {
fmt.Println(err)
os.Exit(1)
}
}
Read a file
package main
import (
"fmt"
"os"
"io"
"codeberg.org/JakobDev/asar-go"
)
func main() {
archive, err := asar.OpenFile("path", &asar.ReadOptions{})
if err != nil {
fmt.Println(err)
os.Exit(1)
}
defer archive.Close()
entry, err := archive.GetEntry("test.txt")
if err != nil {
fmt.Println(err)
os.Exit(1)
}
reader, err := entry.GetReader()
if err != nil {
fmt.Println(err)
os.Exit(1)
}
content, err := io.ReadAll(reader)
if err != nil {
fmt.Println(err)
os.Exit(1)
}
fmt.Println(string(content))
}