Skip to content

Commit

Permalink
Cosmetics - no code behaviour changes (#397)
Browse files Browse the repository at this point in the history
* Revert ioutil deprecation commit

While go 1.16 is 2 years old, I feel like I should not go out of my way
to break the library for users on go versions lower that 1.16. This
commit reverts part of the changes from #392.

* fix some doc comments for go v1.19 rules

* Fix wrong total number of supported mimes

The mistake was introduced in a merge commit.
  • Loading branch information
gabriel-vasile committed Oct 10, 2023
1 parent 3b8e5ee commit 79aa93c
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 21 deletions.
38 changes: 20 additions & 18 deletions internal/magic/binary.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,32 +150,34 @@ func Marc(raw []byte, limit uint32) bool {
}

// Glb matches a glTF model format file.
// GLB is the binary file format representation of 3D models save in
// GLB is the binary file format representation of 3D models saved in
// the GL transmission Format (glTF).
// see more: https://docs.fileformat.com/3d/glb/
// https://www.iana.org/assignments/media-types/model/gltf-binary
// GLB file format is based on little endian and its header structure
// show below:
// GLB uses little endian and its header structure is as follows:
//
// <-- 12-byte header -->
// | magic | version | length |
// | (uint32) | (uint32) | (uint32) |
// | \x67\x6C\x54\x46 | \x01\x00\x00\x00 | ... |
// | g l T F | 1 | ... |
// <-- 12-byte header -->
// | magic | version | length |
// | (uint32) | (uint32) | (uint32) |
// | \x67\x6C\x54\x46 | \x01\x00\x00\x00 | ... |
// | g l T F | 1 | ... |
//
// Visit [glTF specification] and [IANA glTF entry] for more details.
//
// [glTF specification]: https://registry.khronos.org/glTF/specs/2.0/glTF-2.0.html
// [IANA glTF entry]: https://www.iana.org/assignments/media-types/model/gltf-binary
var Glb = prefix([]byte("\x67\x6C\x54\x46\x02\x00\x00\x00"),
[]byte("\x67\x6C\x54\x46\x01\x00\x00\x00"))

// TzIf matches a Time Zone Information Format (TZif) file.
// See more: https://tools.ietf.org/id/draft-murchison-tzdist-tzif-00.html#rfc.section.3
// Its header structure is shown below:
// +---------------+---+
// | magic (4) | <-+-- version (1)
// +---------------+---+---------------------------------------+
// | [unused - reserved for future use] (15) |
// +---------------+---------------+---------------+-----------+
// | isutccnt (4) | isstdcnt (4) | leapcnt (4) |
// +---------------+---------------+---------------+
// | timecnt (4) | typecnt (4) | charcnt (4) |
// +---------------+---+
// | magic (4) | <-+-- version (1)
// +---------------+---+---------------------------------------+
// | [unused - reserved for future use] (15) |
// +---------------+---------------+---------------+-----------+
// | isutccnt (4) | isstdcnt (4) | leapcnt (4) |
// +---------------+---------------+---------------+
// | timecnt (4) | typecnt (4) | charcnt (4) |
func TzIf(raw []byte, limit uint32) bool {
// File is at least 44 bytes (header size).
if len(raw) < 44 {
Expand Down
4 changes: 3 additions & 1 deletion internal/magic/magic.go
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,9 @@ func newXMLSig(localName, xmlns string) xmlSig {
// and, optionally, followed by the arguments for the interpreter.
//
// Ex:
// #! /usr/bin/env php
//
// #! /usr/bin/env php
//
// /usr/bin/env is the interpreter, php is the first and only argument.
func shebang(sigs ...[]byte) Detector {
return func(raw []byte, limit uint32) bool {
Expand Down
3 changes: 2 additions & 1 deletion mimetype.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ package mimetype

import (
"io"
"io/ioutil"
"mime"
"os"
"sync/atomic"
Expand Down Expand Up @@ -47,7 +48,7 @@ func DetectReader(r io.Reader) (*MIME, error) {
// Using atomic because readLimit can be written at the same time in other goroutine.
l := atomic.LoadUint32(&readLimit)
if l == 0 {
in, err = io.ReadAll(r)
in, err = ioutil.ReadAll(r)
if err != nil {
return errMIME, err
}
Expand Down
2 changes: 1 addition & 1 deletion supported_mimes.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
## 172 Supported MIME types
## 173 Supported MIME types
This file is automatically generated when running tests. Do not edit manually.

Extension | MIME type | Aliases
Expand Down

0 comments on commit 79aa93c

Please sign in to comment.