Skip to content

Latest commit

 

History

History
48 lines (32 loc) · 825 Bytes

README.md

File metadata and controls

48 lines (32 loc) · 825 Bytes

ft

Get a file category based on its extension. It was built for a small project I'm working on which should explain why the list does not contain every possibility and its function is simple.

How to use

Import the module...

$ go get github.com/spobly/ft@latest

...use it

package main

import (
	"fmt"
    "errors"
	"github.com/spobly/ft/v2"
)

func main() {
	c, err := ft.GetCategory(".png")

	if err != nil {
       if errors.Is(err, ft.ErrInvalidFormat) {
		// Handle err
	   }

	   if errors.Is(err, ft.ErrNotFound) {
		// Handle err
	   }
	}

	fmt.Println(c)
}

Contributing

This list does and cannot contain every file type and category so if you don't find what you are looking for, simply edit ft.go and create a PR.

I would merge it, you can be sure about that.

Happy hacking