Skip to content

Commit c9ecfdd

Browse files
Cosmetics - no code behaviour changes (#397)
* 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.
1 parent b3da20f commit c9ecfdd

File tree

4 files changed

+26
-21
lines changed

4 files changed

+26
-21
lines changed

internal/magic/binary.go

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -150,32 +150,34 @@ func Marc(raw []byte, limit uint32) bool {
150150
}
151151

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

168170
// TzIf matches a Time Zone Information Format (TZif) file.
169171
// See more: https://tools.ietf.org/id/draft-murchison-tzdist-tzif-00.html#rfc.section.3
170172
// Its header structure is shown below:
171-
// +---------------+---+
172-
// | magic (4) | <-+-- version (1)
173-
// +---------------+---+---------------------------------------+
174-
// | [unused - reserved for future use] (15) |
175-
// +---------------+---------------+---------------+-----------+
176-
// | isutccnt (4) | isstdcnt (4) | leapcnt (4) |
177-
// +---------------+---------------+---------------+
178-
// | timecnt (4) | typecnt (4) | charcnt (4) |
173+
// +---------------+---+
174+
// | magic (4) | <-+-- version (1)
175+
// +---------------+---+---------------------------------------+
176+
// | [unused - reserved for future use] (15) |
177+
// +---------------+---------------+---------------+-----------+
178+
// | isutccnt (4) | isstdcnt (4) | leapcnt (4) |
179+
// +---------------+---------------+---------------+
180+
// | timecnt (4) | typecnt (4) | charcnt (4) |
179181
func TzIf(raw []byte, limit uint32) bool {
180182
// File is at least 44 bytes (header size).
181183
if len(raw) < 44 {

internal/magic/magic.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,9 @@ func newXMLSig(localName, xmlns string) xmlSig {
177177
// and, optionally, followed by the arguments for the interpreter.
178178
//
179179
// Ex:
180-
// #! /usr/bin/env php
180+
//
181+
// #! /usr/bin/env php
182+
//
181183
// /usr/bin/env is the interpreter, php is the first and only argument.
182184
func shebang(sigs ...[]byte) Detector {
183185
return func(raw []byte, limit uint32) bool {

mimetype.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ package mimetype
77

88
import (
99
"io"
10+
"io/ioutil"
1011
"mime"
1112
"os"
1213
"sync/atomic"
@@ -47,7 +48,7 @@ func DetectReader(r io.Reader) (*MIME, error) {
4748
// Using atomic because readLimit can be written at the same time in other goroutine.
4849
l := atomic.LoadUint32(&readLimit)
4950
if l == 0 {
50-
in, err = io.ReadAll(r)
51+
in, err = ioutil.ReadAll(r)
5152
if err != nil {
5253
return errMIME, err
5354
}

supported_mimes.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
## 172 Supported MIME types
1+
## 173 Supported MIME types
22
This file is automatically generated when running tests. Do not edit manually.
33

44
Extension | MIME type | Aliases

0 commit comments

Comments
 (0)