diff --git a/cue/load/config.go b/cue/load/config.go index 8d131dcf5..280232371 100644 --- a/cue/load/config.go +++ b/cue/load/config.go @@ -33,7 +33,6 @@ const ( cueSuffix = ".cue" modDir = "cue.mod" moduleFile = "module.cue" - pkgDir = "pkg" ) // FromArgsUsage is a partial usage message that applications calling @@ -384,8 +383,6 @@ func (c Config) isRoot(dir string) bool { // findRoot returns the module root that's ancestor // of the given absolute directory path, or "" if none was found. func (c Config) findRoot(absDir string) string { - fs := &c.fileSystem - abs := absDir for { if c.isRoot(abs) { @@ -398,21 +395,7 @@ func (c Config) findRoot(absDir string) string { return "" } if len(d) >= len(abs) { - break // reached top of file system, no cue.mod - } - abs = d - } - abs = absDir - - // TODO(legacy): remove this capability at some point. - for { - info, err := fs.stat(filepath.Join(abs, pkgDir)) - if err == nil && info.IsDir() { - return abs - } - d := filepath.Dir(abs) - if len(d) >= len(abs) { - return "" // reached top of file system, no pkg dir. + return "" // reached top of file system, no cue.mod } abs = d } diff --git a/cue/load/import.go b/cue/load/import.go index 2842d48c8..1ab8f31b0 100644 --- a/cue/load/import.go +++ b/cue/load/import.go @@ -97,20 +97,16 @@ func (l *loader) importPkg(pos token.Pos, p *build.Instance) []*build.Instance { genDir := GenPath(cfg.ModuleRoot) if strings.HasPrefix(p.Dir, genDir) { dirs = append(dirs, [2]string{genDir, p.Dir}) - // TODO(legacy): don't support "pkg" // && p.PkgName != "_" - if filepath.Base(genDir) != "pkg" { - for _, sub := range []string{"pkg", "usr"} { - rel, err := filepath.Rel(genDir, p.Dir) - if err != nil { - // should not happen - return retErr( - errors.Wrapf(err, token.NoPos, "invalid path")) - } - base := filepath.Join(cfg.ModuleRoot, modDir, sub) - dir := filepath.Join(base, rel) - dirs = append(dirs, [2]string{base, dir}) + for _, sub := range []string{"pkg", "usr"} { + rel, err := filepath.Rel(genDir, p.Dir) + if err != nil { + // should not happen + return retErr(errors.Wrapf(err, token.NoPos, "invalid path")) } + base := filepath.Join(cfg.ModuleRoot, modDir, sub) + dir := filepath.Join(base, rel) + dirs = append(dirs, [2]string{base, dir}) } } else { dirs = append(dirs, [2]string{cfg.ModuleRoot, p.Dir}) @@ -299,14 +295,6 @@ func (l *loader) importPathFromAbsDir(absDir fsPath, key string) (importPath, er "invalid package %q (root of %s)", key, modDir) } - // TODO(legacy): remove. - case strings.HasPrefix(pkg, "/pkg/"): - pkg = pkg[len("/pkg/"):] - if pkg == "" { - return "", errors.Newf(token.NoPos, - "invalid package %q (root of %s)", key, pkgDir) - } - case l.cfg.Module == "": return "", errors.Newf(token.NoPos, "cannot determine import path for %q (no module)", key) diff --git a/cue/load/search.go b/cue/load/search.go index c821d1b79..acf80e966 100644 --- a/cue/load/search.go +++ b/cue/load/search.go @@ -150,14 +150,12 @@ func (l *loader) matchPackagesInFS(pattern, pkgName string) *match { } pkgDir := filepath.Join(root, modDir) - // TODO(legacy): remove - pkgDir2 := filepath.Join(root, "pkg") _ = c.fileSystem.walk(root, func(path string, entry fs.DirEntry, err errors.Error) errors.Error { if err != nil || !entry.IsDir() { return nil } - if path == pkgDir || path == pkgDir2 { + if path == pkgDir { return skipDir } diff --git a/encoding/openapi/testdata/cue.mod b/encoding/openapi/testdata/cue.mod deleted file mode 100644 index e69de29bb..000000000 diff --git a/encoding/openapi/testdata/cue.mod/module.cue b/encoding/openapi/testdata/cue.mod/module.cue new file mode 100644 index 000000000..f8af9cef9 --- /dev/null +++ b/encoding/openapi/testdata/cue.mod/module.cue @@ -0,0 +1 @@ +module: "" diff --git a/encoding/openapi/testdata/pkg/mod.test/blocks/blocks.cue b/encoding/openapi/testdata/cue.mod/pkg/mod.test/blocks/blocks.cue similarity index 100% rename from encoding/openapi/testdata/pkg/mod.test/blocks/blocks.cue rename to encoding/openapi/testdata/cue.mod/pkg/mod.test/blocks/blocks.cue diff --git a/internal/internal.go b/internal/internal.go index 9c85d0f71..cba333ca7 100644 --- a/internal/internal.go +++ b/internal/internal.go @@ -22,7 +22,6 @@ package internal // import "cuelang.org/go/internal" import ( "bufio" "fmt" - "os" "path/filepath" "strings" @@ -435,17 +434,6 @@ func IsEllipsis(x ast.Decl) bool { // GenPath reports the directory in which to store generated files. func GenPath(root string) string { - info, err := os.Stat(filepath.Join(root, "cue.mod")) - if os.IsNotExist(err) || !info.IsDir() { - // Try legacy pkgDir mode - pkgDir := filepath.Join(root, "pkg") - if err == nil && !info.IsDir() { - return pkgDir - } - if info, err := os.Stat(pkgDir); err == nil && info.IsDir() { - return pkgDir - } - } return filepath.Join(root, "cue.mod", "gen") }