Skip to content

Commit

Permalink
Merge pull request #579 from gopcua/fs/ignore-duplicate-extobj-regs
Browse files Browse the repository at this point in the history
ua: do not panic if the same extension object is registered multiple times
  • Loading branch information
magiconair authored May 6, 2022
2 parents 71397d5 + 2349f0c commit 4e46cdb
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions ua/typereg.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ func (r *TypeRegistry) Lookup(v interface{}) *NodeID {

// Register adds a new type to the registry.
//
// If the id is already registered the function returns an error.
// If the id is already registered as a different type the function returns an error.
//
// Register panics if id is nil.
func (r *TypeRegistry) Register(id *NodeID, v interface{}) error {
Expand All @@ -84,8 +84,8 @@ func (r *TypeRegistry) Register(id *NodeID, v interface{}) error {
typ := reflect.TypeOf(v)
ids := id.String()

if r.types[ids] != nil {
return errors.Errorf("%s is already registered", id)
if cur := r.types[ids]; cur != nil && cur != typ {
return errors.Errorf("%s is already registered as %v", id, cur)
}
r.types[ids] = typ

Expand Down

0 comments on commit 4e46cdb

Please sign in to comment.