magika

package
v0.9.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 9, 2026 License: BSD-3-Clause, GPL-3.0 Imports: 6 Imported by: 0

Documentation

Overview

Package magika provides AI-based file type classification using the Google Magika Rust CLI. The Rust CLI is production-ready with the model embedded in the binary, unlike the experimental Go library which requires ONNX Runtime and separate model assets.

Index

Constants

This section is empty.

Variables

View Source
var MagikaVersion = "1.0.2"

MagikaVersion is the version of the Magika CLI (set at build time via ldflags)

Functions

func Destroy

func Destroy()

Destroy cleans up Magika resources.

func GetVersionInfo

func GetVersionInfo() string

GetVersionInfo returns a formatted string with Magika version info

func HasMagikaSupport

func HasMagikaSupport() bool

HasMagikaSupport returns true when Magika support is compiled in

func Init

func Init(assetsDir, modelName string)

Init locates the magika CLI binary and verifies it works. assetsDir and modelName are ignored (the Rust CLI embeds the model).

func IsEnabled

func IsEnabled() bool

IsEnabled returns true if the Magika CLI has been found and is ready to use.

Types

type Result

type Result struct {
	Label       string
	MimeType    string
	Group       string
	Description string
	IsText      bool
	Score       float64
}

Result holds the Magika classification result for a file.

func Classify

func Classify(filePath string) (*Result, error)

Classify classifies a file at the given path and returns its content type.

func ClassifyBytes

func ClassifyBytes(data []byte) (*Result, error)

ClassifyBytes classifies file content from a byte slice. Writes data to a temp file, runs magika, then removes the temp file.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL