magic

command module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Mar 6, 2024 License: Apache-2.0 Imports: 4 Imported by: 0

README

magic

A native go implementation of the magic file format.

It also includes a CLI that functions similarly to the file command.

There is no reason to use this repository's CLI over the original file command, unless you cannot get the original file command to work on your system. Its primary purpose is as a testing tool for the library.

Usage

package main

import (
    "fmt"
    "log"
    "os"

    "github.com/deitch/magic/pkg/magic"
)

func main() {
    f, err := os.Open(os.Args[1])
    if err != nil {
        log.Fatal(err)
    }
    defer f.Close()

    // GetType takes an io.ReaderAt
    info, err := magic.GetType(f)
    if err != nil {
        log.Fatal(err)
    }
    fmt.Println(info)
}

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
pkg

Jump to

Keyboard shortcuts

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