Skip to content

Improve type class visibility in README.md #156

@RRRRRRR-777

Description

@RRRRRRR-777

The README.md's "Check type class" section uses the IsImage class as an example, but it would be much easier to understand if examples of other file type classes were also included. Please consider improving this.

Below is an example of how I would document it. Please refer to it.
It would also be good to include this in the official documentation.

https://pkg.go.dev/github.com/h2non/filetype

Check type class
```
package main

import (
  "fmt"
  "io/ioutil"

  "github.com/h2non/filetype"
)

func main() {
  buf, _ := ioutil.ReadFile("sample.jpg")

  if filetype.IsImage(buf) {
    fmt.Println("File is an image")
  } else {
    fmt.Println("Not an image")
  }
}
```

**Available File Type Classes**
* IsImage: Checks if the file matches an image format
* IsAudio: Checks if the file matches an audio format
* IsVideo: Checks if the file matches a video format
* IsFont: Checks if the file matches a font format
* IsArchive: Checks if the file matches an archive format
* IsDocument: Checks if the file matches a document format
* IsApplication: Checks if the file matches an application format
* Is: Checks if the file matches the magic number for the specified extension
* IsExtension: Alias for Is()

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions