Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions components/common-go/analytics/analytics.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ type Identity struct {
type IdentifyMessage struct {
Identity

Traits map[string]interface{}
Traits map[string]any
Timestamp time.Time
}

Expand All @@ -31,7 +31,7 @@ type TrackMessage struct {
Identity

Event string
Properties map[string]interface{}
Properties map[string]any
Timestamp time.Time
}

Expand Down
6 changes: 3 additions & 3 deletions components/common-go/grpc/ratelimit.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (
"github.com/prometheus/client_golang/prometheus"
)

type keyFunc func(req interface{}) (string, error)
type keyFunc func(req any) (string, error)

// RateLimit configures the reate limit for a function
type RateLimit struct {
Expand Down Expand Up @@ -78,7 +78,7 @@ func NewRatelimitingInterceptor(f map[string]RateLimit) RatelimitingInterceptor
}

func fieldAccessKey(key string) keyFunc {
return func(req interface{}) (string, error) {
return func(req any) (string, error) {
msg, ok := req.(proto.Message)
if !ok {
return "", status.Errorf(codes.Internal, "request was not a protobuf message")
Expand Down Expand Up @@ -157,7 +157,7 @@ type ratelimitedFunction struct {

// UnaryInterceptor creates a unary interceptor that implements the rate limiting
func (r RatelimitingInterceptor) UnaryInterceptor() grpc.UnaryServerInterceptor {
return func(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (resp interface{}, err error) {
return func(ctx context.Context, req any, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (resp any, err error) {
f, ok := r.functions[info.FullMethod]
if !ok {
return handler(ctx, req)
Expand Down
56 changes: 28 additions & 28 deletions components/common-go/log/export.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ func WithContext(ctx context.Context) *logrus.Entry {
//
// Note that it doesn't log until you call Debug, Print, Info, Warn, Fatal
// or Panic on the Entry it returns.
func WithField(key string, value interface{}) *logrus.Entry {
func WithField(key string, value any) *logrus.Entry {
return Log.WithField(key, value)
}

Expand All @@ -50,136 +50,136 @@ func WithTime(t time.Time) *logrus.Entry {
}

// Trace logs a message at level Trace on the standard logger.
func Trace(args ...interface{}) {
func Trace(args ...any) {
Log.Trace(args...)
}

// Debug logs a message at level Debug on the standard logger.
func Debug(args ...interface{}) {
func Debug(args ...any) {
Log.Debug(args...)
}

// Print logs a message at level Info on the standard logger.
func Print(args ...interface{}) {
func Print(args ...any) {
Log.Print(args...)
}

// Info logs a message at level Info on the standard logger.
func Info(args ...interface{}) {
func Info(args ...any) {
Log.Info(args...)
}

// Warn logs a message at level Warn on the standard logger.
func Warn(args ...interface{}) {
func Warn(args ...any) {
Log.Warn(args...)
}

// Warning logs a message at level Warn on the standard logger.
func Warning(args ...interface{}) {
func Warning(args ...any) {
Log.Warning(args...)
}

// Error logs a message at level Error on the standard logger.
func Error(args ...interface{}) {
func Error(args ...any) {
Log.Error(args...)
}

// Panic logs a message at level Panic on the standard logger.
func Panic(args ...interface{}) {
func Panic(args ...any) {
Log.Panic(args...)
}

// Fatal logs a message at level Fatal on the standard logger then the process will exit with status set to 1.
func Fatal(args ...interface{}) {
func Fatal(args ...any) {
Log.Fatal(args...)
}

// Tracef logs a message at level Trace on the standard logger.
func Tracef(format string, args ...interface{}) {
func Tracef(format string, args ...any) {
Log.Tracef(format, args...)
}

// Debugf logs a message at level Debug on the standard logger.
func Debugf(format string, args ...interface{}) {
func Debugf(format string, args ...any) {
Log.Debugf(format, args...)
}

// Printf logs a message at level Info on the standard logger.
func Printf(format string, args ...interface{}) {
func Printf(format string, args ...any) {
Log.Printf(format, args...)
}

// Infof logs a message at level Info on the standard logger.
func Infof(format string, args ...interface{}) {
func Infof(format string, args ...any) {
Log.Infof(format, args...)
}

// Warnf logs a message at level Warn on the standard logger.
func Warnf(format string, args ...interface{}) {
func Warnf(format string, args ...any) {
Log.Warnf(format, args...)
}

// Warningf logs a message at level Warn on the standard logger.
func Warningf(format string, args ...interface{}) {
func Warningf(format string, args ...any) {
Log.Warningf(format, args...)
}

// Errorf logs a message at level Error on the standard logger.
func Errorf(format string, args ...interface{}) {
func Errorf(format string, args ...any) {
Log.Errorf(format, args...)
}

// Panicf logs a message at level Panic on the standard logger.
func Panicf(format string, args ...interface{}) {
func Panicf(format string, args ...any) {
Log.Panicf(format, args...)
}

// Fatalf logs a message at level Fatal on the standard logger then the process will exit with status set to 1.
func Fatalf(format string, args ...interface{}) {
func Fatalf(format string, args ...any) {
Log.Fatalf(format, args...)
}

// Traceln logs a message at level Trace on the standard logger.
func Traceln(args ...interface{}) {
func Traceln(args ...any) {
Log.Traceln(args...)
}

// Debugln logs a message at level Debug on the standard logger.
func Debugln(args ...interface{}) {
func Debugln(args ...any) {
Log.Debugln(args...)
}

// Println logs a message at level Info on the standard logger.
func Println(args ...interface{}) {
func Println(args ...any) {
Log.Println(args...)
}

// Infoln logs a message at level Info on the standard logger.
func Infoln(args ...interface{}) {
func Infoln(args ...any) {
Log.Infoln(args...)
}

// Warnln logs a message at level Warn on the standard logger.
func Warnln(args ...interface{}) {
func Warnln(args ...any) {
Log.Warnln(args...)
}

// Warningln logs a message at level Warn on the standard logger.
func Warningln(args ...interface{}) {
func Warningln(args ...any) {
Log.Warningln(args...)
}

// Errorln logs a message at level Error on the standard logger.
func Errorln(args ...interface{}) {
func Errorln(args ...any) {
Log.Errorln(args...)
}

// Panicln logs a message at level Panic on the standard logger.
func Panicln(args ...interface{}) {
func Panicln(args ...any) {
Log.Panicln(args...)
}

// Fatalln logs a message at level Fatal on the standard logger then the process will exit with status set to 1.
func Fatalln(args ...interface{}) {
func Fatalln(args ...any) {
Log.Fatalln(args...)
}
12 changes: 6 additions & 6 deletions components/common-go/log/redact.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ var (

// RedactJSON removes sensitive data from JSON structures
func RedactJSON(data []byte) (res []byte, err error) {
var jsonBlob interface{}
var jsonBlob any
err = json.Unmarshal(data, &jsonBlob)
if err != nil {
return data, err
Expand All @@ -32,14 +32,14 @@ func RedactJSON(data []byte) (res []byte, err error) {
}

// blatently copied from https://github.com/cloudfoundry/lager/blob/master/json_redacter.go#L45
func redactValue(data *interface{}) interface{} {
func redactValue(data *any) any {
if data == nil {
return data
}

if a, ok := (*data).([]interface{}); ok {
if a, ok := (*data).([]any); ok {
redactArray(&a)
} else if m, ok := (*data).(map[string]interface{}); ok {
} else if m, ok := (*data).(map[string]any); ok {
redactObject(&m)
} else if s, ok := (*data).(string); ok {
for _, prohibited := range redactedFields {
Expand All @@ -52,13 +52,13 @@ func redactValue(data *interface{}) interface{} {
return (*data)
}

func redactArray(data *[]interface{}) {
func redactArray(data *[]any) {
for i := range *data {
redactValue(&((*data)[i]))
}
}

func redactObject(data *map[string]interface{}) {
func redactObject(data *map[string]any) {
for k, v := range *data {
for _, prohibited := range redactedFields {
if strings.Contains(strings.ToLower(fmt.Sprintf("%v", k)), prohibited) {
Expand Down
6 changes: 3 additions & 3 deletions components/common-go/testing/fixtures.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,12 @@ type FixtureTest struct {
Path string
GoldPath func(path string) string
Test FixtureTestFunc
Fixture func() interface{}
Gold func() interface{}
Fixture func() any
Gold func() any
}

// FixtureTestFunc implements the actual fixture test
type FixtureTestFunc func(t *testing.T, fixture interface{}) interface{}
type FixtureTestFunc func(t *testing.T, fixture any) any

// Run executes the fixture test - do not forget to call this one
func (ft *FixtureTest) Run() {
Expand Down
2 changes: 1 addition & 1 deletion components/common-go/util/duration.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ type Duration time.Duration

// UnmarshalJSON parses the duration to a time.Duration
func (d *Duration) UnmarshalJSON(b []byte) error {
var v interface{}
var v any
if err := json.Unmarshal(b, &v); err != nil {
return err
}
Expand Down
16 changes: 8 additions & 8 deletions components/content-service-api/go/blobs.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading