Skip to content

Commit

Permalink
Make several vars into consts (#3068)
Browse files Browse the repository at this point in the history
  • Loading branch information
ash2k committed Aug 9, 2022
1 parent eb55e60 commit ff51300
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions trace/tracestate.go
Expand Up @@ -21,7 +21,7 @@ import (
"strings"
)

var (
const (
maxListMembers = 32

listDelimiter = ","
Expand All @@ -32,17 +32,19 @@ var (
withTenantKeyFormat = `[a-z0-9][_0-9a-z\-\*\/]{0,240}@[a-z][_0-9a-z\-\*\/]{0,13}`
valueFormat = `[\x20-\x2b\x2d-\x3c\x3e-\x7e]{0,255}[\x21-\x2b\x2d-\x3c\x3e-\x7e]`

keyRe = regexp.MustCompile(`^((` + noTenantKeyFormat + `)|(` + withTenantKeyFormat + `))$`)
valueRe = regexp.MustCompile(`^(` + valueFormat + `)$`)
memberRe = regexp.MustCompile(`^\s*((` + noTenantKeyFormat + `)|(` + withTenantKeyFormat + `))=(` + valueFormat + `)\s*$`)

errInvalidKey errorConst = "invalid tracestate key"
errInvalidValue errorConst = "invalid tracestate value"
errInvalidMember errorConst = "invalid tracestate list-member"
errMemberNumber errorConst = "too many list-members in tracestate"
errDuplicate errorConst = "duplicate list-member in tracestate"
)

var (
keyRe = regexp.MustCompile(`^((` + noTenantKeyFormat + `)|(` + withTenantKeyFormat + `))$`)
valueRe = regexp.MustCompile(`^(` + valueFormat + `)$`)
memberRe = regexp.MustCompile(`^\s*((` + noTenantKeyFormat + `)|(` + withTenantKeyFormat + `))=(` + valueFormat + `)\s*$`)
)

type member struct {
Key string
Value string
Expand Down

0 comments on commit ff51300

Please sign in to comment.