Skip to content

Commit

Permalink
Replace EOL github.com/pmezard/go-difflib by `github.com/google/go-…
Browse files Browse the repository at this point in the history
…cmp` (elastic#37228)

* replace github.com/pmezard/go-difflib by github.com/google/go-cmp
  • Loading branch information
AndersonQ authored Dec 4, 2023
1 parent bfc1b11 commit e62be5d
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 64 deletions.
78 changes: 39 additions & 39 deletions NOTICE.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18042,11 +18042,11 @@ Contents of probable licence file $GOMODCACHE/github.com/google/flatbuffers@v23.

--------------------------------------------------------------------------------
Dependency : github.com/google/go-cmp
Version: v0.5.9
Version: v0.6.0
Licence type (autodetected): BSD-3-Clause
--------------------------------------------------------------------------------

Contents of probable licence file $GOMODCACHE/github.com/google/go-cmp@v0.5.9/LICENSE:
Contents of probable licence file $GOMODCACHE/github.com/google/go-cmp@v0.6.0/LICENSE:

Copyright (c) 2017 The Go Authors. All rights reserved.

Expand Down Expand Up @@ -21367,43 +21367,6 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.


--------------------------------------------------------------------------------
Dependency : github.com/pmezard/go-difflib
Version: v1.0.0
Licence type (autodetected): BSD-3-Clause
--------------------------------------------------------------------------------

Contents of probable licence file $GOMODCACHE/github.com/pmezard/go-difflib@v1.0.0/LICENSE:

Copyright (c) 2013, Patrick Mezard
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:

Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
The names of its contributors may not be used to endorse or promote
products derived from this software without specific prior written
permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.


--------------------------------------------------------------------------------
Dependency : github.com/prometheus/client_model
Version: v0.2.0
Expand Down Expand Up @@ -47114,6 +47077,43 @@ Redistribution and use in source and binary forms, with or without modification,
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.


--------------------------------------------------------------------------------
Dependency : github.com/pmezard/go-difflib
Version: v1.0.0
Licence type (autodetected): BSD-3-Clause
--------------------------------------------------------------------------------

Contents of probable licence file $GOMODCACHE/github.com/pmezard/go-difflib@v1.0.0/LICENSE:

Copyright (c) 2013, Patrick Mezard
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:

Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
The names of its contributors may not be used to endorse or promote
products derived from this software without specific prior written
permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.


--------------------------------------------------------------------------------
Dependency : github.com/power-devops/perfstat
Version: v0.0.0-20210106213030-5aafc221ea8c
Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ require (
github.com/golang/snappy v0.0.4
github.com/gomodule/redigo v1.8.3
github.com/google/flatbuffers v23.3.3+incompatible
github.com/google/go-cmp v0.5.9
github.com/google/go-cmp v0.6.0
github.com/google/gopacket v1.1.19
github.com/google/uuid v1.3.0
github.com/gorhill/cronexpr v0.0.0-20180427100037-88b0669f7d75
Expand Down Expand Up @@ -128,7 +128,7 @@ require (
github.com/osquery/osquery-go v0.0.0-20231108163517-e3cde127e724
github.com/pierrre/gotestcover v0.0.0-20160517101806-924dca7d15f0
github.com/pkg/errors v0.9.1
github.com/pmezard/go-difflib v1.0.0
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/prometheus/client_model v0.2.0
github.com/prometheus/common v0.30.0
github.com/prometheus/procfs v0.9.0
Expand Down
3 changes: 2 additions & 1 deletion go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1040,8 +1040,9 @@ github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/
github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.7/go.mod h1:n+brtR0CgQNWTVd5ZUFpTBC8YFBDLK/h/bpaJ8/DtOE=
github.com/google/go-cmp v0.5.8/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38=
github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
github.com/google/go-containerregistry v0.5.1/go.mod h1:Ct15B4yir3PLOP5jsy0GNeYVaIZs/MK/Jz5any1wFW0=
github.com/google/go-querystring v1.0.0/go.mod h1:odCYkC5MyYFN7vkCjXpyrEuKhc/BUO6wN/zVPAxq5ck=
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
Expand Down
14 changes: 4 additions & 10 deletions x-pack/filebeat/processors/decode_cef/decode_cef_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
"reflect"
"testing"

"github.com/pmezard/go-difflib/difflib"
"github.com/google/go-cmp/cmp"
"github.com/stretchr/testify/assert"

"github.com/elastic/beats/v7/libbeat/beat"
Expand Down Expand Up @@ -226,7 +226,7 @@ func readCEFSamples(t testing.TB, source string) []mapstr.M {
t.Fatal(err)
}

var samples []mapstr.M
var samples []mapstr.M //nolint:prealloc // size is unknown and it's a test
s := bufio.NewScanner(f)
for s.Scan() {
data := s.Bytes()
Expand Down Expand Up @@ -315,14 +315,8 @@ func assertEqual(t testing.TB, expected, actual interface{}) bool {
expJSON, _ := json.MarshalIndent(expected, "", " ")
actJSON, _ := json.MarshalIndent(actual, "", " ")

diff, _ := difflib.GetUnifiedDiffString(difflib.UnifiedDiff{
A: difflib.SplitLines(string(expJSON)),
B: difflib.SplitLines(string(actJSON)),
FromFile: "Expected",
ToFile: "Actual",
Context: 1,
})
t.Errorf("Expected and actual are different:\n%s", diff)
t.Errorf("Expected and actual are different:\n%s",
cmp.Diff(string(expJSON), string(actJSON)))
return false
}

Expand Down
17 changes: 5 additions & 12 deletions x-pack/winlogbeat/module/testing.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import (
"testing"
"time"

"github.com/pmezard/go-difflib/difflib"
"github.com/google/go-cmp/cmp"
"github.com/stretchr/testify/assert"

devtools "github.com/elastic/beats/v7/dev-tools/mage"
Expand Down Expand Up @@ -151,7 +151,6 @@ func testIngestPipeline(t *testing.T, pipeline, pattern string, p *params) {
}

var events []mapstr.M
//nolint:errcheck // All the errors returned here are from mapstr.M queries and may be ignored.
for i, p := range k.Processed {
err = wintest.ErrorMessage(p)
if err != nil {
Expand Down Expand Up @@ -215,14 +214,8 @@ func assertEqual(t testing.TB, expected, actual interface{}) bool {
expJSON, _ := json.MarshalIndent(expected, "", " ")
actJSON, _ := json.MarshalIndent(actual, "", " ")

diff, _ := difflib.GetUnifiedDiffString(difflib.UnifiedDiff{
A: difflib.SplitLines(string(expJSON)),
B: difflib.SplitLines(string(actJSON)),
FromFile: "Expected",
ToFile: "Actual",
Context: 1,
})
t.Errorf("Expected and actual are different:\n%s", diff)
t.Errorf("Expected and actual are different:\n%s",
cmp.Diff(string(expJSON), string(actJSON)))
return false
}

Expand Down Expand Up @@ -278,7 +271,7 @@ func normalize(t testing.TB, m mapstr.M) mapstr.M {

func filterEvent(m mapstr.M, ignores []string) mapstr.M {
for _, f := range ignores {
m.Delete(f) //nolint:errcheck // Deleting a thing that doesn't exist is ok.
m.Delete(f)
}
return m
}
Expand All @@ -295,7 +288,7 @@ func lowercaseGUIDs(m mapstr.M) mapstr.M {
continue
}
if uppercaseGUIDRegex.MatchString(str) {
m.Put(k, strings.ToLower(str)) //nolint:errcheck // Can't fail because k has been obtained from m.
m.Put(k, strings.ToLower(str))
}
}
return m
Expand Down

0 comments on commit e62be5d

Please sign in to comment.