mirror of
https://github.com/opencloud-eu/opencloud.git
synced 2025-12-24 14:50:39 -05:00
12 lines
292 B
Go
12 lines
292 B
Go
// Package structs provides some utility functions for dealing with structs.
|
|
package structs
|
|
|
|
// CopyOrZeroValue returns a copy of s if s is not nil otherwise the zero value of T will be returned.
|
|
func CopyOrZeroValue[T any](s *T) *T {
|
|
cp := new(T)
|
|
if s != nil {
|
|
*cp = *s
|
|
}
|
|
return cp
|
|
}
|