Help us shape the future of Go! Take the 2026 Go Developer Survey

metadata

package
v0.8.2 Latest Latest
Warning

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

Go to latest
Published: Oct 19, 2026 License: GPL-3.0 Imports: 12 Imported by: 0

Documentation

Overview

Package metadata — GoCut project extractor (.gocut).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Register

func Register(extractor Extractor)

Register adds a custom extractor ahead of built-ins so domain formats can override signature or extension detection.

func RegisterCustom

func RegisterCustom(name string, match MatchFunc, extract ExtractFunc)

RegisterCustom registers a named custom extractor from functions.

func Unregister

func Unregister(name string)

Unregister removes extractors with the supplied name.

Types

type DateMetadata

type DateMetadata struct {
	Date   time.Time
	Source string
}

DateMetadata is embedded media date information read from a file.

func Read

func Read(path, ext string) (DateMetadata, bool, error)

Read returns embedded taken/creation date metadata for supported files.

type ExtractFunc

type ExtractFunc func(Sample) (Result, error)

ExtractFunc extracts metadata from a sample.

type Extractor

type Extractor interface {
	Name() string
	Match(Sample) bool
	Extract(Sample) (Result, error)
}

Extractor is the in-process extension point for built-in and custom formats.

func NewFuncExtractor

func NewFuncExtractor(name string, match MatchFunc, extract ExtractFunc) Extractor

NewFuncExtractor creates an extractor from match and extraction functions.

type FuncExtractor

type FuncExtractor struct {
	// contains filtered or unexported fields
}

FuncExtractor adapts functions to Extractor.

func (*FuncExtractor) Extract

func (e *FuncExtractor) Extract(sample Sample) (Result, error)

Extract runs the extractor function.

func (*FuncExtractor) Match

func (e *FuncExtractor) Match(sample Sample) bool

Match reports whether the extractor handles the sample.

func (*FuncExtractor) Name

func (e *FuncExtractor) Name() string

Name returns the extractor name.

type MatchFunc

type MatchFunc func(Sample) bool

MatchFunc reports whether an extractor can handle a sample.

type Result

type Result struct {
	Format   string            `json:"format"`
	MIMEType string            `json:"mime_type,omitempty"`
	Category string            `json:"category,omitempty"`
	Date     DateMetadata      `json:"date,omitempty"`
	Fields   map[string]string `json:"fields,omitempty"`
}

Result contains format detection and the metadata extracted from a file.

func Extract

func Extract(path, ext string) (Result, error)

Extract detects a file's format and extracts metadata using the first matching built-in or custom extractor.

type Sample

type Sample struct {
	Path      string
	Extension string
	Head      []byte
	Tail      []byte
	Size      int64
}

Sample is the bounded file view supplied to metadata extractors.

Jump to

Keyboard shortcuts

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