magika

package
v0.16.2 Latest Latest
Warning

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

Go to latest
Published: Nov 9, 2026 License: BSD-3-Clause, GPL-3.0 Imports: 15 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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 Classifier added in v0.16.0

type Classifier struct {
	Digest string
	// contains filtered or unexported fields
}

func NewClassifier added in v0.16.0

func NewClassifier() (*Classifier, error)

func (*Classifier) Classify added in v0.16.0

func (c *Classifier) Classify(ctx context.Context, path string) (*Result, error)

func (*Classifier) ClassifyBytes added in v0.16.0

func (c *Classifier) ClassifyBytes(ctx context.Context, data []byte) (*Result, error)

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