261119.1 d1753f14c7293dd5f2cdb3b5b4488e94ab87a52a The project is dirview and its command drvu
commit time warp
The name is final. NAME, back from WORKING_NAME, holds drvu, and everything the tool names follows: the binaries drvu, drvu-public and drvu-syntax, DRVU_ADDR and the other variables, ~/.local/state/drvu, the journal tag, .drvu-follow, /_drvu/ and the systemd units.
The project, its Go module and its Debian packages are dirview and dirview-syntax. The Makefile takes that name from the module path as PACKAGE, so the name test now guards both names.
Old names stop working: WWW_ADDR, ~/.local/state/www, the www package and running www servers stay until removed.
Changes to name_test.go. All files
name_test.go
@@ -1,4 +1,4 @@-package www+package dirview import ( "go/scanner"@@ -10,21 +10,34 @@ import ( "testing" ) -// The name lives in WORKING_NAME alone. Go code takes it from progName, the Makefile-// and the package files from WORKING_NAME, so a tracked file names the program-// only in prose: comments, README.md, doc/ and go.mod, which Go needs as-// a literal, as it does the module's path where a main under cmd/ imports-// it. A name such as www also occurs inside words that belong to others,-// which foreign strips first.+// The program's name lives in NAME alone and the project's in go.mod. Go+// code takes the first from progName; the Makefile reads NAME and takes the+// project's from the module, and fills both into the package files. So a+// tracked file names either only in prose: comments, README.md and doc/,+// or where Go needs a literal: go.mod, the package clause and the import+// in each main under cmd/. func TestNameHasOneSource(t *testing.T) { needGit(t) out, err := exec.Command("git", "ls-files").Output() if err != nil { t.Fatalf("git ls-files: %v", err) }- lower := strings.ToLower(progName)+ mod, err := exec.Command("go", "list", "-m").Output()+ if err != nil {+ t.Fatalf("go list -m: %v", err)+ }+ names := []string{strings.ToLower(progName), strings.ToLower(path.Base(strings.TrimSpace(string(mod))))}+ holds := func(s string) bool {+ s = strings.ToLower(s)+ for _, n := range names {+ if strings.Contains(s, n) {+ return true+ }+ }+ return false+ } for _, f := range strings.Fields(string(out)) {- if f == "WORKING_NAME" || f == "go.mod" || f == "README.md" || strings.HasPrefix(f, "doc/") || strings.HasPrefix(f, "assets/fonts/") {+ if f == "NAME" || f == "go.mod" || f == "README.md" || strings.HasPrefix(f, "doc/") || strings.HasPrefix(f, "assets/fonts/") { continue } src, err := os.ReadFile(f)@@ -51,20 +64,16 @@ func TestNameHasOneSource(t *testing.T) { if imports { continue }- if (tok == token.STRING || tok == token.CHAR) && strings.Contains(foreign.Replace(strings.ToLower(lit)), lower) {+ if (tok == token.STRING || tok == token.CHAR) && holds(lit) { t.Errorf("%s: %s", fset.Position(pos), lit) } } continue } for i, line := range strings.Split(string(src), "\n") {- if !strings.HasPrefix(strings.TrimSpace(line), "#") && strings.Contains(foreign.Replace(strings.ToLower(line)), lower) {+ if !strings.HasPrefix(strings.TrimSpace(line), "#") && holds(line) { t.Errorf("%s:%d: %s", f, i+1, line) } } } }--// foreign removes the words that hold www without naming the program: web-// hosts, the host prefix a forge link may carry and the form media type.-var foreign = strings.NewReplacer("://www.", "://", `"www."`, "", "x-www-form-urlencoded", "")