Skip to content

Commit 5213437

Browse files
committed
fix dogoc comments
1 parent 5a42f07 commit 5213437

3 files changed

Lines changed: 23 additions & 20 deletions

File tree

id.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ import "sync/atomic"
44

55
var internalID int64
66

7-
// Create next unique id for errorx entities
8-
// All equality comparison should take id into account, lest there be some false positive matches
7+
// nextInternalID creates next unique id for errorx entities.
8+
// All equality comparison should take id into account, lest there be some false positive matches.
99
func nextInternalID() int64 {
1010
return atomic.AddInt64(&internalID, 1)
1111
}

modifier.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
package errorx
22

3-
// Modifier is a way to change a default behaviour for an error type, directly or via type hierarchy
4-
// Modification is intentionally one-way, as it provides much more clarity
5-
// If there is a modifier on a type or a namespace, all its descendants definitely have the same default behaviour
6-
// If some of a subtypes must lack a specific modifier, then the modifier must be removed from the common ancestor
3+
// Modifier is a way to change a default behaviour for an error type, directly or via type hierarchy.
4+
// Modification is intentionally one-way, as it provides much more clarity.
5+
// If there is a modifier on a type or a namespace, all its descendants definitely have the same default behaviour.
6+
// If some of a subtypes must lack a specific modifier, then the modifier must be removed from the common ancestor.
77
type TypeModifier int
88

99
const (

namespace.go

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,13 @@ package errorx
22

33
import "fmt"
44

5-
// A namespace is a way go group a number of error types together, and each error type belongs to exactly one namespace
6-
// Namespaces may form hierarchy, with child namespaces inheriting the traits and modifiers of a parent
7-
// Those modifiers and traits are then passed upon all error types in the namespace
8-
// In formatting, a dot notation is used, for example: namespace.sub_namespace.type.subtype
5+
// Namespace is a way go group a number of error types together, and each error type belongs to exactly one namespace.
6+
// Namespaces may form hierarchy, with child namespaces inheriting the traits and modifiers of a parent.
7+
// Those modifiers and traits are then passed upon all error types in the namespace.
8+
// In formatting, a dot notation is used, for example:
9+
//
10+
// namespace.sub_namespace.type.subtype
11+
//
912
type Namespace struct {
1013
parent *Namespace
1114
id int64
@@ -14,46 +17,46 @@ type Namespace struct {
1417
modifiers modifiers
1518
}
1619

17-
// Namespace itself is not comparable, so a key be used instead
20+
// Namespace itself is not comparable, so a key be used instead.
1821
type NamespaceKey struct {
1922
id int64
2023
name string
2124
}
2225

23-
// Define a namespace with a name and, optionally, a number of inheritable traits
26+
// NewNamespace defines a namespace with a name and, optionally, a number of inheritable traits.
2427
func NewNamespace(name string, traits ...Trait) Namespace {
2528
namespace := newNamespace(nil, name, traits...)
2629
globalRegistry.registerNamespace(namespace)
2730
return namespace
2831
}
2932

30-
// Define a child namespace that inherits all that is defined for a parent and, optionally, adds some more
33+
// NewSubNamespace defines a child namespace that inherits all that is defined for a parent and, optionally, adds some more.
3134
func (n Namespace) NewSubNamespace(name string, traits ...Trait) Namespace {
3235
namespace := newNamespace(&n, name, traits...)
3336
globalRegistry.registerNamespace(namespace)
3437
return namespace
3538
}
3639

37-
// One-time modification of defaults in error creation
40+
// ApplyModifiers makes a one-time modification of defaults in error creation.
3841
func (n Namespace) ApplyModifiers(modifiers ...TypeModifier) Namespace {
3942
n.modifiers = n.modifiers.ReplaceWith(newTypeModifiers(modifiers...))
4043
return n
4144
}
4245

43-
// Create a new type within a namespace that inherits all that is defined for namespace and, optionally, adds some more
46+
// NewType creates a new type within a namespace that inherits all that is defined for namespace and, optionally, adds some more.
4447
func (n Namespace) NewType(typeName string, traits ...Trait) *Type {
4548
return NewType(n, typeName, traits...)
4649
}
4750

48-
// A comparison key
51+
// Key returns a comparison key for namespace.
4952
func (n Namespace) Key() NamespaceKey {
5053
return NamespaceKey{
5154
id: n.id,
5255
name: n.name,
5356
}
5457
}
5558

56-
// Check whether or not an error belongs either to this namespace or some of its sub-namespaces
59+
// IsNamespaceOf checks whether or not an error belongs either to this namespace or some of its sub-namespaces.
5760
func (n Namespace) IsNamespaceOf(t *Type) bool {
5861
namespace := t.namespace
5962
other := &namespace
@@ -69,7 +72,7 @@ func (n Namespace) IsNamespaceOf(t *Type) bool {
6972
return false
7073
}
7174

72-
// Returns a full name of a namespace
75+
// FullName returns a full name of a namespace.
7376
func (n Namespace) FullName() string {
7477
return n.name
7578
}
@@ -78,8 +81,8 @@ func (n Namespace) String() string {
7881
return n.name
7982
}
8083

81-
// Returns the immediate parent namespace, if present
82-
// The use of this function outside of a system layer that handles error types (see TypeSubscriber) is a code smell
84+
// Parent returns the immediate parent namespace, if present.
85+
// The use of this function outside of a system layer that handles error types (see TypeSubscriber) is a code smell.
8386
func (n Namespace) Parent() *Namespace {
8487
return n.parent
8588
}

0 commit comments

Comments
 (0)