MCPcopy Create free account
hub / github.com/TheThingsNetwork/lorawan-stack / messageFormatArguments

Function messageFormatArguments

pkg/errors/definitions.go:118–133  ·  view source on GitHub ↗
(messageFormat string)

Source from the content-addressed store, hash-verified

116var messageFormatArgument = regexp.MustCompile(`\{[\s]*([a-z0-9_]+)`)
117
118func messageFormatArguments(messageFormat string) (args []string) {
119 for _, matches := range messageFormatArgument.FindAllStringSubmatch(messageFormat, -1) {
120 if len(matches) == 2 {
121 args = append(args, matches[1])
122 }
123 }
124 unique := make([]string, 0, len(args))
125 seen := make(map[string]struct{}, len(args))
126 for _, arg := range args {
127 if _, ok := seen[arg]; !ok {
128 unique = append(unique, arg)
129 seen[arg] = struct{}{}
130 }
131 }
132 return unique
133}
134
135func define(code uint32, name, messageFormat string, publicAttributes ...string) *Definition {
136 ns := namespace(3)

Callers 2

setErrorDetailsFunction · 0.85
defineFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected