fix(audit): ensure template creation errors are audited (#7315)

This commit is contained in:
Colin Adler
2023-04-27 18:55:34 -05:00
committed by GitHub
parent 77d9937dc4
commit 59efa4a528
3 changed files with 55 additions and 17 deletions
+12 -3
View File
@@ -17,10 +17,19 @@ func NilOrEmpty(s *string) bool {
return s == nil || *s == ""
}
// NilToEmpty coalesces a nil str to the empty string.
func NilToEmpty(s *string) string {
// NilToEmpty coalesces a nil value to the empty value.
func NilToEmpty[T any](s *T) T {
var def T
if s == nil {
return ""
return def
}
return *s
}
// NilToDefault coalesces a nil value to the provided default value.
func NilToDefault[T any](s *T, def T) T {
if s == nil {
return def
}
return *s
}