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.
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)
}
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