binary

package
v1.0.4 Latest Latest
Warning

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

Go to latest
Published: Jul 16, 2025 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var BinaryExtensions = map[string]bool{
	".exe": true, ".dll": true, ".so": true, ".dylib": true,
	".bin": true, ".obj": true, ".o": true, ".a": true,
	".lib": true, ".pyc": true, ".pyo": true, ".pyd": true,
	".class": true, ".jar": true, ".war": true, ".ear": true,
	".png": true, ".jpg": true, ".jpeg": true, ".gif": true,
	".bmp": true, ".ico": true, ".zip": true, ".tar": true,
	".gz": true, ".rar": true, ".7z": true, ".pdf": true,
}

List of extensions to exclude

Functions

func IsBinaryFile

func IsBinaryFile(filepath string, cache *Cache) bool

IsBinaryFile detects if a file is binary based on its extension, mime type or content

Types

type Cache

type Cache struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

Cache manages a persistent cache of binary file detection results

func NewCache

func NewCache() *Cache

NewCache creates a new cache for binary files

func (*Cache) Get

func (bc *Cache) Get(key string) (bool, bool)

Get retrieves a value from the cache

func (*Cache) Load

func (bc *Cache) Load() error

Load loads the cache from disk

func (*Cache) Save

func (bc *Cache) Save() error

Save saves the cache to disk

func (*Cache) Set

func (bc *Cache) Set(key string, value bool)

Set adds a value to the cache

Jump to

Keyboard shortcuts

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