gofixt

package module
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2024 License: MIT Imports: 13 Imported by: 0

README

Go-Fix-Ext

Fix binary file extensions using magic numbers header signature

Build Status License

# Run the app in scan mode
gofixt --dir=./tmp scan
# Output
| File                   | Mime             | Orig ext. | Real ext. | Notes         |
| ----                   | ----             | --------- | --------- | -----         |
| <dir>/png-picture2.png | image/png        | .png      | .png      |               |
| <dir>/archive.tar.gz   | application/gzip | .gz       | .gz       |               |
| <dir>/chat             | unknown          |           |           |               |
| <dir>/empty.pdf        | unknown          | .pdf      |           | File is empty |
| <dir>/pdf-doc.pdf      | application/pdf  | .pdf      | .pdf      |               |
| <dir>/pdf-doc.txt      | application/pdf  | .txt      | .pdf      |               |
| <dir>/png-picture1.jpg | image/png        | .jpg      | .png      |               |
7 file(s) processed and 0 file(s) fixed in 211.589µs

# Run the app in fix mode
gofixt --dir=./tmp fix
| File                   | Mime             | Orig ext. | Real ext. | Notes                                     |
| ----                   | ----             | --------- | --------- | -----                                     |
| <dir>/png-picture2.png | image/png        | .png      | .png      |                                           |
| <dir>/archive.tar.gz   | application/gzip | .gz       | .gz       |                                           |
| <dir>/chat             | unknown          |           |           |                                           |
| <dir>/empty.pdf        | unknown          | .pdf      |           | File is empty                             |
| <dir>/pdf-doc.pdf      | application/pdf  | .pdf      | .pdf      |                                           |
| <dir>/pdf-doc.txt      | application/pdf  | .txt      | .pdf      | File with the same name is already exists |
| <dir>/png-picture1.jpg | image/png        | .jpg      | .png      | Fixed                                     |
7 file(s) processed and 1 file(s) fixed in 246.946µs

Contents

Install

# Install the gofixt binary in your $GOPATH/bin directory
go install github.com/alexandermac/gom/cmd/gom

Usage

CLI

Usage: gofixt [flags] command

Flags:
  --dir    Scanning directory (absolute or relative path)
  --silent Don't print report

Commands:
  scan     Scans files in the provided directory recursively. Prints files info in a table format
  fix      Scans files in the provided directory recursively and fixes their extensions (when needed). Prints files info in a table format
  help     Shows this help
  version  Prints app version

Examples:
  gofixt --dir=~/images scan
  gofixt --dir=~/files --silent fix

License

Licensed under the MIT license.

Author

Alexander Mac

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Fix

func Fix(dirPath string, silent bool) error

func Scan

func Scan(dirPath string, silent bool) error

Types

type TableWriter

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

func NewTableWriter

func NewTableWriter() *TableWriter

func (*TableWriter) AddHeader

func (tw *TableWriter) AddHeader()

func (*TableWriter) AddRow

func (tw *TableWriter) AddRow(fi *_FileInfo)

func (*TableWriter) Finish

func (tw *TableWriter) Finish() error

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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