tronnet/workflows: Static Analysis -- Golang / static-go (push) Successful in 30s
use json encoding for route body parameters, implement modify user/group/pool operations, simplify schema by using comon lib struct tags and RequireAll and AtLeastOne helper functions, properly implement locadb as Backend interface
20 lines
504 B
Go
20 lines
504 B
Go
package localdb
|
|
|
|
import "reflect"
|
|
|
|
// MergeNonZero overwrites fields in dst with fields in src iff src is not a zero value.
|
|
func MergeNonZero[T any](dst *T, src *T) {
|
|
vDst := reflect.ValueOf(dst).Elem()
|
|
vSrc := reflect.ValueOf(src).Elem()
|
|
|
|
for i := 0; i < vDst.NumField(); i++ {
|
|
dstField := vDst.Field(i)
|
|
srcField := vSrc.Field(i)
|
|
|
|
// Only set if the field is exported (CanSet) and the source is not a zero value
|
|
if dstField.CanSet() && !srcField.IsZero() {
|
|
dstField.Set(srcField)
|
|
}
|
|
}
|
|
}
|