diff --git a/pkg/gen.go b/pkg/gen.go index 766ad8894b1..35cb57c551d 100644 --- a/pkg/gen.go +++ b/pkg/gen.go @@ -42,7 +42,6 @@ import ( "log" "math/big" "os" - "path" "path/filepath" "sort" "strings" @@ -58,9 +57,6 @@ import ( const genFile = "pkg.go" -//go:embed packages.txt -var packagesStr string - type headerParams struct { GoPkg string CUEPkg string @@ -99,20 +95,8 @@ func main() { log.SetFlags(log.Lshortfile) log.SetOutput(os.Stdout) - var packagesList []string - for _, pkg := range strings.Fields(packagesStr) { - if pkg == "path" { - // TODO remove this special case. Currently the path - // pkg.go file cannot be generated automatically but that - // will be possible when we can attach arbitrary signatures - // to builtin functions. - continue - } - packagesList = append(packagesList, path.Join(pkgParent, pkg)) - } - cfg := &packages.Config{Mode: packages.NeedName | packages.NeedFiles | packages.NeedTypes | packages.NeedSyntax} - pkgs, err := packages.Load(cfg, packagesList...) + pkgs, err := packages.Load(cfg, "./...") if err != nil { fmt.Fprintf(os.Stderr, "load: %v\n", err) os.Exit(1) @@ -121,8 +105,20 @@ func main() { os.Exit(1) } for _, pkg := range pkgs { - if err := generate(pkg); err != nil { - log.Fatalf("%s: %v", pkg, err) + switch { + case pkg.PkgPath == pkgParent: + // The pkg package itself should not be generated. + case strings.Contains(pkg.PkgPath, "/internal"): + // Internal packages are not for public use. + case pkg.PkgPath == "cuelang.org/go/pkg/path": + // TODO remove this special case. Currently the path + // pkg.go file cannot be generated automatically but that + // will be possible when we can attach arbitrary signatures + // to builtin functions. + default: + if err := generate(pkg); err != nil { + log.Fatalf("%s: %v", pkg, err) + } } } } diff --git a/pkg/packages.txt b/pkg/packages.txt deleted file mode 100644 index e46a4404e7b..00000000000 --- a/pkg/packages.txt +++ /dev/null @@ -1,31 +0,0 @@ -regexp -encoding/json -encoding/base64 -encoding/yaml -encoding/hex -encoding/csv -uuid -time -list -strings -path -math/bits -math -crypto/sha256 -crypto/ed25519 -crypto/sha512 -crypto/md5 -crypto/sha1 -crypto/hmac -tool -tool/os -tool/cli -tool/exec -tool/file -tool/http -struct -net -html -strconv -text/template -text/tabwriter