mirror of
https://github.com/open-policy-agent/opa.git
synced 2026-08-19 23:11:23 -06:00
e43ef0a979
Earlier this evening I tried to run the Go [modernize](https://pkg.go.dev/golang.org/x/tools/gopls/internal/analysis/modernize) analyzer on OPA. That didn't go as planned: - https://github.com/golang/go/issues/73661 - https://github.com/golang/go/issues/73663 While we wait for that to be fixed, I figured an old-fashioned search-and-replace across the repo may work for at least the `interface{}` to `any` conversion. That should help make it easier to see the other fixes as applied by the modernize tool once it has had those issues resolved. Signed-off-by: Anders Eknert <anders@styra.com>
40 lines
1.5 KiB
Go
40 lines
1.5 KiB
Go
// Copyright 2016 The OPA Authors. All rights reserved.
|
|
// Use of this source code is governed by an Apache2
|
|
// license that can be found in the LICENSE file.
|
|
|
|
package ast
|
|
|
|
import (
|
|
v1 "github.com/open-policy-agent/opa/v1/ast"
|
|
)
|
|
|
|
// Compare returns an integer indicating whether two AST values are less than,
|
|
// equal to, or greater than each other.
|
|
//
|
|
// If a is less than b, the return value is negative. If a is greater than b,
|
|
// the return value is positive. If a is equal to b, the return value is zero.
|
|
//
|
|
// Different types are never equal to each other. For comparison purposes, types
|
|
// are sorted as follows:
|
|
//
|
|
// nil < Null < Boolean < Number < String < Var < Ref < Array < Object < Set <
|
|
// ArrayComprehension < ObjectComprehension < SetComprehension < Expr < SomeDecl
|
|
// < With < Body < Rule < Import < Package < Module.
|
|
//
|
|
// Arrays and Refs are equal if and only if both a and b have the same length
|
|
// and all corresponding elements are equal. If one element is not equal, the
|
|
// return value is the same as for the first differing element. If all elements
|
|
// are equal but a and b have different lengths, the shorter is considered less
|
|
// than the other.
|
|
//
|
|
// Objects are considered equal if and only if both a and b have the same sorted
|
|
// (key, value) pairs and are of the same length. Other comparisons are
|
|
// consistent but not defined.
|
|
//
|
|
// Sets are considered equal if and only if the symmetric difference of a and b
|
|
// is empty.
|
|
// Other comparisons are consistent but not defined.
|
|
func Compare(a, b any) int {
|
|
return v1.Compare(a, b)
|
|
}
|