// Copyright 2022 schukai GmbH // SPDX-License-Identifier: AGPL-3.0 package configuration import ( "gitlab.schukai.com/oss/libraries/go/utilities/pathfinder" ) // // Copy implements the xflags.Copyable interface. func (s *Settings[C]) Copy(m map[string]any) { if s == nil { panic("struct is not initialized") } s.Lock() defer s.Unlock() errorCount := len(s.errors) defer func() { if len(s.errors) > errorCount { s.notifyErrorHooks() } }() copyOf := func(s C) C { return s } c := copyOf(s.config) for k, v := range m { err := pathfinder.SetValue(&c, k, v) if err != nil { s.errors = append(s.errors, err) } } s.setConfigInternal(c, false) }