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) {
7272}
7373
7474// 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_- ]*$".
7676//
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 .
8080func validIdentifier (s string ) bool {
8181 if len (s ) < 1 {
8282 return false
@@ -86,7 +86,7 @@ func validIdentifier(s string) bool {
8686 case c >= 'a' && c <= 'z' :
8787 case c >= 'A' && c <= 'Z' :
8888 case c == '_' :
89- case i > 0 && c >= '0' && c <= '9' :
89+ case i > 0 && ( c == '-' || c >= '0' && c <= '9' ) :
9090
9191 default :
9292 return false
Original file line number Diff line number Diff line change @@ -42,8 +42,9 @@ func TestValidIdentifier(t *testing.T) {
4242 {"underscore first" , "__x64_syscall" , false },
4343 {"contains number" , "bpf_trace_run1" , false },
4444 {"underscore" , "_" , false },
45- {"contains dash" , "-EINVAL" , true },
45+ {"leading dash" , "-EINVAL" , true },
4646 {"contains number" , "all0wed" , false },
47+ {"contains dash" , "trace-group" , false },
4748 }
4849
4950 for _ , tt := range tests {
You can’t perform that action at this time.
0 commit comments