Skip to content

Commit

Permalink
refactor: Add comment for GetDefaultIfNil (#167)
Browse files Browse the repository at this point in the history
  • Loading branch information
art-tapin committed Apr 28, 2023
1 parent 77006de commit 3eb9a2b
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions pkg/common/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ func FetchEnv(key string, def string) string {
return val
}

// 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
Expand Down

0 comments on commit 3eb9a2b

Please sign in to comment.