diff --git a/Gopkg.lock b/Gopkg.lock index 02a86fda..91cd5d42 100644 --- a/Gopkg.lock +++ b/Gopkg.lock @@ -37,12 +37,12 @@ revision = "4c0e84591b9aa9e6dcfdf3e020114cd81f89d5f9" [[projects]] - digest = "1:ec6271918b59b872a2d25e374569a4f75f1839d91e4191470c297b7eaaaf7641" + digest = "1:f9adc21a937e5da643ea14a3488cb7506788876737a5e205394e508627a6eec8" name = "github.com/dimchansky/utfbom" packages = ["."] pruneopts = "NUT" - revision = "5448fe645cb1964ba70ac8f9f2ffe975e61a536c" - version = "v1.0.0" + revision = "d2133a1ce379ef6fa992b0514a77146c60db9d1c" + version = "v1.1.0" [[projects]] digest = "1:cb4e216bd9f58866f42dc65893455b24f879b026fdaa1ecc3aafff625fdb5a66" diff --git a/collector/textfile.go b/collector/textfile.go index b1bd33c0..f5a61dc7 100644 --- a/collector/textfile.go +++ b/collector/textfile.go @@ -288,19 +288,9 @@ fileLoop: } func checkBOM(encoding utfbom.Encoding) error { - bom := "" - switch encoding { - case utfbom.Unknown, utfbom.UTF8: + if encoding == utfbom.Unknown || encoding == utfbom.UTF8 { return nil - case utfbom.UTF16BigEndian: - bom = "UTF16BigEndian" - case utfbom.UTF16LittleEndian: - bom = "UTF16LittleEndian" - case utfbom.UTF32BigEndian: - bom = "UTF32BigEndian" - case utfbom.UTF32LittleEndian: - bom = "UTF32LittleEndian" } - return fmt.Errorf(bom) + return fmt.Errorf(encoding.String()) } diff --git a/vendor/github.com/dimchansky/utfbom/utfbom.go b/vendor/github.com/dimchansky/utfbom/utfbom.go index 648184a1..77a303e5 100644 --- a/vendor/github.com/dimchansky/utfbom/utfbom.go +++ b/vendor/github.com/dimchansky/utfbom/utfbom.go @@ -32,6 +32,24 @@ const ( UTF32LittleEndian ) +// String returns a user-friendly string representation of the encoding. Satisfies fmt.Stringer interface. +func (e Encoding) String() string { + switch e { + case UTF8: + return "UTF8" + case UTF16BigEndian: + return "UTF16BigEndian" + case UTF16LittleEndian: + return "UTF16LittleEndian" + case UTF32BigEndian: + return "UTF32BigEndian" + case UTF32LittleEndian: + return "UTF32LittleEndian" + default: + return "Unknown" + } +} + const maxConsecutiveEmptyReads = 100 // Skip creates Reader which automatically detects BOM (Unicode Byte Order Mark) and removes it as necessary.