File tree Expand file tree Collapse file tree 2 files changed +7
-6
lines changed Expand file tree Collapse file tree 2 files changed +7
-6
lines changed Original file line number Diff line number Diff line change @@ -72,11 +72,11 @@ func RandomGroup(prefix string) (string, error) {
72
72
}
73
73
74
74
// validIdentifier implements the equivalent of a regex match
75
- // against "^[a-zA-Z_][0-9a-zA-Z_]*$".
75
+ // against "^[a-zA-Z_][0-9a-zA-Z_- ]*$".
76
76
//
77
- // Trace event groups, names and kernel symbols must adhere to this set
78
- // of characters. Non-empty, first character must not be a number, all
79
- // characters must be alphanumeric or underscore .
77
+ // Trace event groups, names and kernel symbols must adhere to this set of
78
+ // characters. Non-empty, first character must not be a number or hyphen , all
79
+ // characters must be alphanumeric, underscore or hyphen .
80
80
func validIdentifier (s string ) bool {
81
81
if len (s ) < 1 {
82
82
return false
@@ -86,7 +86,7 @@ func validIdentifier(s string) bool {
86
86
case c >= 'a' && c <= 'z' :
87
87
case c >= 'A' && c <= 'Z' :
88
88
case c == '_' :
89
- case i > 0 && c >= '0' && c <= '9' :
89
+ case i > 0 && ( c == '-' || c >= '0' && c <= '9' ) :
90
90
91
91
default :
92
92
return false
Original file line number Diff line number Diff line change @@ -42,8 +42,9 @@ func TestValidIdentifier(t *testing.T) {
42
42
{"underscore first" , "__x64_syscall" , false },
43
43
{"contains number" , "bpf_trace_run1" , false },
44
44
{"underscore" , "_" , false },
45
- {"contains dash" , "-EINVAL" , true },
45
+ {"leading dash" , "-EINVAL" , true },
46
46
{"contains number" , "all0wed" , false },
47
+ {"contains dash" , "trace-group" , false },
47
48
}
48
49
49
50
for _ , tt := range tests {
You can’t perform that action at this time.
0 commit comments