-
-
Save jdolitsky/eaaae0f4ab8f3a9d3c95ab0727f31001 to your computer and use it in GitHub Desktop.
Parse an apk with Go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"os" | |
apkrepo "gitlab.alpinelinux.org/alpine/go/repository" | |
) | |
func main() { | |
if len(os.Args) != 2 { | |
fmt.Println("Usage: go run main.go <path_to_apk>") | |
os.Exit(1) | |
} | |
f, err := os.Open(os.Args[1]) | |
if err != nil { | |
panic(err) | |
} | |
defer f.Close() | |
apk, err := apkrepo.ParsePackage(f) | |
if err != nil { | |
panic(err) | |
} | |
fmt.Printf("Name: %s\n", apk.Name) | |
fmt.Printf("Version: %s\n", apk.Version) | |
fmt.Printf("Arch: %s\n", apk.Arch) | |
fmt.Printf("Desc: %s\n", apk.Description) | |
fmt.Printf("Checksum: %s\n", apk.ChecksumString()) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment