-
Notifications
You must be signed in to change notification settings - Fork 33
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: upgrade to Go 1.20 #239
Conversation
Codecov Report
@@ Coverage Diff @@
## main #239 +/- ##
==========================================
- Coverage 64.79% 62.21% -2.59%
==========================================
Files 33 33
Lines 3224 3165 -59
==========================================
- Hits 2089 1969 -120
- Misses 972 1015 +43
- Partials 163 181 +18
Flags with carried forward coverage won't be shown. Click here to find out more.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looking good
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You may also include:
Line 2 in 6f3b3fd
FROM golang:1.19 as builder |
This has already been updated to 1.20 at https://github.com/Kuadrant/kuadrant-operator/pull/239/files#diff-dd2c0eb6ea5cfc6c4bd4eac30934e2d5746747af48fef6da689e85b752f39557R2 🤔 |
@@ -6,6 +6,7 @@ import ( | |||
"reflect" | |||
|
|||
"github.com/go-logr/logr" | |||
"golang.org/x/exp/slices" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This slice package (https://pkg.go.dev/golang.org/x/[email protected]/slices) is provided as part of Go 1.21 standard library https://pkg.go.dev/[email protected] but is not available in Go 1.20
func Ptr[T any](t T) *T { | ||
return &t | ||
} | ||
|
||
// FetchEnv fetches the value of the environment variable with the specified key, | ||
// or returns the default value if the variable is not found or has an empty value. | ||
// If an error occurs during the lookup, the function returns the default value. | ||
// The key and default value parameters must be valid strings. | ||
func FetchEnv(key string, def string) string { | ||
val, ok := os.LookupEnv(key) | ||
if !ok { | ||
return def | ||
} | ||
|
||
return val | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removing as it's already provided by
// Contains checks if the given target string is present in the slice of strings 'slice'. | ||
// It returns true if the target string is found in the slice, false otherwise. | ||
func Contains[T comparable](slice []T, target T) bool { | ||
for idx := range slice { | ||
if slice[idx] == target { | ||
return true | ||
} | ||
} | ||
return false | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removing as it's already provided by
// SliceCopy copies the elements from the input slice into the output slice, and returns the output slice. | ||
func SliceCopy[T any](s1 []T) []T { | ||
s2 := make([]T, len(s1)) | ||
copy(s2, s1) | ||
return s2 | ||
} | ||
|
||
// ReverseSlice creates a reversed copy of the input slice. | ||
func ReverseSlice[T any](input []T) []T { | ||
inputLen := len(input) | ||
output := make([]T, inputLen) | ||
|
||
for i, n := range input { | ||
j := inputLen - i - 1 | ||
|
||
output[j] = n | ||
} | ||
|
||
return output | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removing as it's already provided by
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice contributions!
PS: I need to learn about new features from 1.20 😝
// GetDefaultIfNil returns the value of a pointer argument, or a default value if the pointer is nil. | ||
func GetDefaultIfNil[T any](val *T, def T) T { | ||
if reflect.ValueOf(val).IsNil() { | ||
return def | ||
} | ||
return *val | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removing as its already provided by:
// ContainsObjectKey tells whether a contains x | ||
func ContainsObjectKey(a []client.ObjectKey, x client.ObjectKey) bool { | ||
for _, n := range a { | ||
if x == n { | ||
return true | ||
} | ||
} | ||
return false | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removing as it's already provided by:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@guicassolato Sure, I've ran through https://github.com/Kuadrant/kuadrant-operator/blob/main/doc/user-guides/authenticated-rl-for-app-developers.md and it's working as expected 🎉 I'm going to merge this now 👍 |
Resolves: #236