Skip to content

Commit

Permalink
support package paths with dashes
Browse files Browse the repository at this point in the history
From x/mod/module.CheckImportPath:

    A valid path element is a non-empty string made up of ASCII letters,
    ASCII digits, and limited ASCII punctuation: - . _ and ~. It must
    not end with a dot (U+002E), nor contain two dots in a row.

We handled dots and slashes in benchmain_test.go, but not the rest yet.
This resulted in the regular expression matching from the main process
not behaving correctly, as it matches the benchmark names with \w.
  • Loading branch information
mvdan committed Aug 7, 2024
1 parent ab9221a commit 56ce6c4
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion benchmain_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,10 +116,14 @@ func BenchmarkGeneratedBenchinit(b *testing.B) {
}
}

// Turn "golang.org/x/foo" into "GolangOrgXFoo".
// Turn "golang.org/x/foo" into "GolangOrgXFoo",
// and "foo.bar/~user/go-baz" into "FooBarUserGoBaz".
name := pkg.ImportPath
name = strings.ReplaceAll(name, "/", " ")
name = strings.ReplaceAll(name, ".", " ")
name = strings.ReplaceAll(name, "~", " ")
name = strings.ReplaceAll(name, "-", " ")
name = strings.ReplaceAll(name, "_", " ")
name = strings.Title(name)
name = strings.ReplaceAll(name, " ", "")

Expand Down

0 comments on commit 56ce6c4

Please sign in to comment.