Skip to content

Commit

Permalink
Backport generic Ptr helper func
Browse files Browse the repository at this point in the history
  • Loading branch information
bbrks committed Jan 28, 2025
1 parent 86e8e43 commit 7b0ae9e
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions base/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -851,6 +851,12 @@ func LogLevelPtr(value LogLevel) *LogLevel {
return &value
}

// Ptr returns a pointer to the given literal.
// This is useful for wrapping around function calls that return a value, where you can't just use `&`.
func Ptr[T any](v T) *T {
return &v
}

// StringPtr returns a pointer to the given string literal.
func StringPtr(value string) *string {
return &value
Expand Down

0 comments on commit 7b0ae9e

Please sign in to comment.