summaryrefslogtreecommitdiffstats
path: root/vendor
diff options
context:
space:
mode:
authorTommy Nguyen <remyabel@gmail.com>2018-08-16 07:10:25 -0400
committerTommy Nguyen <remyabel@gmail.com>2018-08-16 07:17:47 -0400
commit74d81ae0806c87da8b9e504dd581c574e7396ee3 (patch)
tree68623f74caff7d645176978457d1b1bd2a1311e2 /vendor
parent3a31b84d1ab8a99ae04ebb6c17ca26710182b724 (diff)
[rebase] Fix errors; update dependencies
Argument must be []byte not string Don't commit bomtest.txt
Diffstat (limited to 'vendor')
-rw-r--r--vendor/github.com/spkg/bom/LICENSE.md21
-rw-r--r--vendor/github.com/spkg/bom/bom.go39
-rw-r--r--vendor/github.com/spkg/bom/discard_go14.go12
-rw-r--r--vendor/github.com/spkg/bom/discard_go15.go10
4 files changed, 82 insertions, 0 deletions
diff --git a/vendor/github.com/spkg/bom/LICENSE.md b/vendor/github.com/spkg/bom/LICENSE.md
new file mode 100644
index 000000000..931b189e4
--- /dev/null
+++ b/vendor/github.com/spkg/bom/LICENSE.md
@@ -0,0 +1,21 @@
+The MIT License (MIT)
+
+Copyright (c) 2015 John Jeffery
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
diff --git a/vendor/github.com/spkg/bom/bom.go b/vendor/github.com/spkg/bom/bom.go
new file mode 100644
index 000000000..93b811c6d
--- /dev/null
+++ b/vendor/github.com/spkg/bom/bom.go
@@ -0,0 +1,39 @@
+// Package bom is used to clean up UTF-8 Byte Order Marks.
+package bom
+
+import (
+ "bufio"
+ "io"
+)
+
+const (
+ bom0 = 0xef
+ bom1 = 0xbb
+ bom2 = 0xbf
+)
+
+// Clean returns b with the 3 byte BOM stripped off the front if it is present.
+// If the BOM is not present, then b is returned.
+func Clean(b []byte) []byte {
+ if len(b) >= 3 &&
+ b[0] == bom0 &&
+ b[1] == bom1 &&
+ b[2] == bom2 {
+ return b[3:]
+ }
+ return b
+}
+
+// NewReader returns an io.Reader that will skip over initial UTF-8 byte order marks.
+func NewReader(r io.Reader) io.Reader {
+ buf := bufio.NewReader(r)
+ b, err := buf.Peek(3)
+ if err != nil {
+ // not enough bytes
+ return buf
+ }
+ if b[0] == bom0 && b[1] == bom1 && b[2] == bom2 {
+ discardBytes(buf, 3)
+ }
+ return buf
+}
diff --git a/vendor/github.com/spkg/bom/discard_go14.go b/vendor/github.com/spkg/bom/discard_go14.go
new file mode 100644
index 000000000..782cd0624
--- /dev/null
+++ b/vendor/github.com/spkg/bom/discard_go14.go
@@ -0,0 +1,12 @@
+// +build !go1.5
+
+package bom
+
+import "bufio"
+
+func discardBytes(buf *bufio.Reader, n int) {
+ // cannot use the buf.Discard method as it was introduced in Go 1.5
+ for i := 0; i < n; i++ {
+ buf.ReadByte()
+ }
+}
diff --git a/vendor/github.com/spkg/bom/discard_go15.go b/vendor/github.com/spkg/bom/discard_go15.go
new file mode 100644
index 000000000..2d17d5c5e
--- /dev/null
+++ b/vendor/github.com/spkg/bom/discard_go15.go
@@ -0,0 +1,10 @@
+// +build go1.5
+
+package bom
+
+import "bufio"
+
+func discardBytes(buf *bufio.Reader, n int) {
+ // the Discard method was introduced in Go 1.5
+ buf.Discard(n)
+}