Use any in place of interface{} (#7566)

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>
This commit is contained in:
Anders Eknert
2025-05-12 13:57:48 +02:00
committed by GitHub
parent f3cb38dc05
commit e43ef0a979
336 changed files with 2872 additions and 2872 deletions
+2 -2
View File
@@ -60,12 +60,12 @@ func NewBasic(inner http.Handler, compiler func() *ast.Compiler, store storage.S
// SetBodyOnContext adds the parsed input value to the context. This function is only
// exposed for test purposes.
func SetBodyOnContext(ctx context.Context, x interface{}) context.Context {
func SetBodyOnContext(ctx context.Context, x any) context.Context {
return v1.SetBodyOnContext(ctx, x)
}
// GetBodyOnContext returns the parsed input from the request context if it exists.
// The authorizer saves the parsed input on the context when it runs.
func GetBodyOnContext(ctx context.Context) (interface{}, bool) {
func GetBodyOnContext(ctx context.Context) (any, bool) {
return v1.GetBodyOnContext(ctx)
}
+1 -1
View File
@@ -27,7 +27,7 @@ const (
type ErrorV1 = v1.ErrorV1
// NewErrorV1 returns a new ErrorV1 object.
func NewErrorV1(code, f string, a ...interface{}) *ErrorV1 {
func NewErrorV1(code, f string, a ...any) *ErrorV1 {
return v1.NewErrorV1(code, f, a...)
}
+2 -2
View File
@@ -40,12 +40,12 @@ func Error(w http.ResponseWriter, status int, err *types.ErrorV1) {
// Deprecated: This method is problematic when using a non-200 status `code`: if
// encoding the payload fails, it'll print "superfluous call to WriteHeader()"
// logs.
func JSON(w http.ResponseWriter, code int, v interface{}, pretty bool) {
func JSON(w http.ResponseWriter, code int, v any, pretty bool) {
v1.JSON(w, code, v, pretty)
}
// JSONOK is a helper for status "200 OK" responses
func JSONOK(w http.ResponseWriter, v interface{}, pretty bool) {
func JSONOK(w http.ResponseWriter, v any, pretty bool) {
v1.JSONOK(w, v, pretty)
}