Skip to content

Remove Deprecated methods in README.md #157

@sabi1125

Description

@sabi1125
package main

import (
  "fmt"
  "io/ioutil"

  "github.com/h2non/filetype"
)

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

  kind, _ := filetype.Match(buf)
  if kind == filetype.Unknown {
    fmt.Println("Unknown file type")
    return
  }

  fmt.Printf("File type: %s. MIME: %s\n", kind.Extension, kind.MIME.Value)
}

io/ioutil's ReadFile is Deprecated since go version v1.16.

Diagnostics:
1. ioutil.ReadFile is deprecated: As of Go 1.16, this function simply calls [os.ReadFile]. [default]
2. Call of ioutil.ReadFile should be inlined [inline_call]

It would be better to use the os.ReadFile in the example instead.

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