From a118de484a5ef024faacb7cf26d5abda279ff617 Mon Sep 17 00:00:00 2001 From: Ilya Tribusean Date: Sun, 15 Feb 2026 14:16:19 +0200 Subject: [PATCH 1/3] go bump --- go.mod | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/go.mod b/go.mod index b1194d1..3076237 100644 --- a/go.mod +++ b/go.mod @@ -1,5 +1,5 @@ module github.com/slash3b/utfbom -go 1.25 +go 1.26 require github.com/nalgeon/be v0.2.0 From 687bcc9ba58a318d9fa5444297dfa0d43d8d9c35 Mon Sep 17 00:00:00 2001 From: Ilya Tribusean Date: Sun, 15 Feb 2026 14:17:58 +0200 Subject: [PATCH 2/3] go fix applied --- utfbom.go | 9 ++------- utfbom_test.go | 6 +++--- 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/utfbom.go b/utfbom.go index 9ad9b42..1562960 100644 --- a/utfbom.go +++ b/utfbom.go @@ -10,6 +10,7 @@ import ( "bytes" "errors" "io" + "slices" "sync" ) @@ -92,13 +93,7 @@ func DetectEncoding[T ~string | ~[]byte](input T) Encoding { // AnyOf reports whether the Encoding value equals any of the given Encoding values. // It returns true if a match is found, otherwise false. func (e Encoding) AnyOf(es ...Encoding) bool { - for _, enc := range es { - if enc == e { - return true - } - } - - return false + return slices.Contains(es, e) } // String returns the human-readable name of the encoding. diff --git a/utfbom_test.go b/utfbom_test.go index 1d0e669..a89e3e6 100644 --- a/utfbom_test.go +++ b/utfbom_test.go @@ -172,21 +172,21 @@ func ExampleReader() { urd := utfbom.NewReader(bytes.NewReader([]byte(csvFile))) crd := csv.NewReader(urd) - out := "" + var out strings.Builder for { row, err := crd.Read() if err != nil { break } - out += strings.Join(row, ",") + out.WriteString(strings.Join(row, ",")) } fmt.Println("detected encoding:", urd.Enc) fmt.Println("before") fmt.Println(hex.Dump([]byte(csvFile))) fmt.Println("after") - fmt.Println(hex.Dump([]byte(out))) + fmt.Println(hex.Dump([]byte(out.String()))) // output: //detected encoding: UTF8 From aeb3af7d55c905ac351ca09bd4e1438f97162c9a Mon Sep 17 00:00:00 2001 From: Ilya Tribusean Date: Sun, 15 Feb 2026 14:30:19 +0200 Subject: [PATCH 3/3] bump golangci as well --- .github/workflows/golangci-lint.yml | 2 +- readme.md | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/golangci-lint.yml b/.github/workflows/golangci-lint.yml index 740ba6c..f85c65a 100644 --- a/.github/workflows/golangci-lint.yml +++ b/.github/workflows/golangci-lint.yml @@ -21,4 +21,4 @@ jobs: - name: golangci-lint uses: golangci/golangci-lint-action@v8 with: - version: v2.4.0 + version: v2.9.0 diff --git a/readme.md b/readme.md index 023c146..4ec3f00 100644 --- a/readme.md +++ b/readme.md @@ -1,3 +1,5 @@ +This is a **fork** of [github.com/dimchansky/utfbom](https://github.com/dimchansky/utfbom). + # utfbom [![Godoc](https://godoc.org/github.com/slash3b/utfbom?status.png)](https://godoc.org/github.com/slash3b/utfbom) [![License](https://img.shields.io/:license-apache-blue.svg)](https://opensource.org/licenses/Apache-2.0)