From 2aa75752d1da6ff8d5418e5e84da80a337ecb7f5 Mon Sep 17 00:00:00 2001 From: Alexandre Rostovtsev Date: Mon, 7 Aug 2023 10:40:10 -0400 Subject: [PATCH] trivial: Fix golint errors (#495) Google's linter is complaining about the following: * comment on exported method Int.Cmp should be of the form "Cmp ..." * receiver name x should be consistent with previous receiver name i for Int * exported method Float.Cmp should have comment or be unexported * receiver name x should be consistent with previous receiver name f for Float * method parameter y_ should be y --- starlark/int.go | 17 +++++++++-------- starlark/value.go | 8 +++++--- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/starlark/int.go b/starlark/int.go index a264e9d2..93567c5e 100644 --- a/starlark/int.go +++ b/starlark/int.go @@ -191,15 +191,16 @@ func (i Int) Hash() (uint32, error) { return 12582917 * uint32(lo+3), nil } -// Required by the TotallyOrdered interface -func (x Int) Cmp(v Value, depth int) (int, error) { - y := v.(Int) - xSmall, xBig := x.get() - ySmall, yBig := y.get() - if xBig != nil || yBig != nil { - return x.bigInt().Cmp(y.bigInt()), nil +// Cmp implements comparison of two Int values. +// Required by the TotallyOrdered interface. +func (i Int) Cmp(v Value, depth int) (int, error) { + j := v.(Int) + iSmall, iBig := i.get() + jSmall, jBig := j.get() + if iBig != nil || jBig != nil { + return i.bigInt().Cmp(j.bigInt()), nil } - return signum64(xSmall - ySmall), nil // safe: int32 operands + return signum64(iSmall - jSmall), nil // safe: int32 operands } // Float returns the float value nearest i. diff --git a/starlark/value.go b/starlark/value.go index da217951..1f14a297 100644 --- a/starlark/value.go +++ b/starlark/value.go @@ -465,9 +465,11 @@ func isFinite(f float64) bool { return math.Abs(f) <= math.MaxFloat64 } -func (x Float) Cmp(y_ Value, depth int) (int, error) { - y := y_.(Float) - return floatCmp(x, y), nil +// Cmp implements comparison of two Float values. +// Required by the TotallyOrdered interface. +func (f Float) Cmp(v Value, depth int) (int, error) { + g := v.(Float) + return floatCmp(f, g), nil } // floatCmp performs a three-valued comparison on floats,