From 40b0368695f5fae70d636844c1c7fd2b9c326e96 Mon Sep 17 00:00:00 2001 From: xushiwei Date: Mon, 13 Jan 2025 22:11:46 +0800 Subject: [PATCH 1/5] mv *.go => tool/*.go --- cmd/chore/gopfmt/gopfmt.go | 4 +-- cmd/chore/goptestgo/goptestgo.go | 6 ++--- cmd/internal/build/build.go | 18 ++++++------- cmd/internal/doc/doc.go | 12 ++++----- cmd/internal/gengo/go.go | 18 ++++++------- cmd/internal/gopfmt/fmt.go | 5 ++-- cmd/internal/gopget/get.go | 4 +-- cmd/internal/install/install.go | 18 ++++++------- cmd/internal/mod/tidy.go | 6 ++--- cmd/internal/run/run.go | 16 ++++++------ cmd/internal/test/test.go | 18 ++++++------- cmd/internal/watch/watch.go | 4 +-- _gendeps.go => tool/_gendeps.go | 2 +- .../build_install_run.go | 26 +++++++++---------- gengo.go => tool/gengo.go | 8 +++--- imp.go => tool/imp.go | 2 +- load.go => tool/load.go | 6 ++--- outline.go => tool/outline.go | 6 ++--- tidy.go => tool/tidy.go | 6 ++--- x/langserver/server.go | 10 +++---- 20 files changed, 97 insertions(+), 98 deletions(-) rename _gendeps.go => tool/_gendeps.go (99%) rename build_install_run.go => tool/build_install_run.go (88%) rename gengo.go => tool/gengo.go (97%) rename imp.go => tool/imp.go (99%) rename load.go => tool/load.go (98%) rename outline.go => tool/outline.go (95%) rename tidy.go => tool/tidy.go (94%) diff --git a/cmd/chore/gopfmt/gopfmt.go b/cmd/chore/gopfmt/gopfmt.go index 7cef6c6d5..48f81ef93 100644 --- a/cmd/chore/gopfmt/gopfmt.go +++ b/cmd/chore/gopfmt/gopfmt.go @@ -30,7 +30,7 @@ import ( goformat "go/format" - "github.com/goplus/gop" + "github.com/goplus/gop/tool" "github.com/goplus/gop/format" ) @@ -132,7 +132,7 @@ func (w *walker) walk(path string, d fs.DirEntry, err error) error { dir, _ := filepath.Split(path) fn, ok := w.dirMap[dir] if !ok { - if mod, err := gop.LoadMod(path); err == nil { + if mod, err := tool.LoadMod(path); err == nil { fn = func(ext string) (ok bool, class bool) { switch ext { case ".go", ".gop": diff --git a/cmd/chore/goptestgo/goptestgo.go b/cmd/chore/goptestgo/goptestgo.go index 43f426e4a..ce216ad2b 100644 --- a/cmd/chore/goptestgo/goptestgo.go +++ b/cmd/chore/goptestgo/goptestgo.go @@ -28,7 +28,7 @@ import ( "path/filepath" "time" - "github.com/goplus/gop" + "github.com/goplus/gop/tool" "github.com/goplus/gop/x/gocmd" "github.com/goplus/gop/x/gopenv" ) @@ -43,7 +43,7 @@ func fileIsDirty(srcMod time.Time, destFile string) bool { func runGoFile(dir, file, fname string) { gopEnv := gopenv.Get() - conf := &gop.Config{Gop: gopEnv} + conf := &tool.Config{Gop: gopEnv} confCmd := &gocmd.BuildConfig{Gop: gopEnv} fi, err := os.Stat(file) if err != nil { @@ -53,7 +53,7 @@ func runGoFile(dir, file, fname string) { hash := sha1.Sum([]byte(absFile)) outFile := dir + "g" + base64.RawURLEncoding.EncodeToString(hash[:]) + fname if fileIsDirty(fi.ModTime(), outFile) { - err = gop.RunFiles(outFile, []string{file}, nil, conf, confCmd) + err = tool.RunFiles(outFile, []string{file}, nil, conf, confCmd) if err != nil { os.Remove(outFile) switch e := err.(type) { diff --git a/cmd/internal/build/build.go b/cmd/internal/build/build.go index dc55ea728..8d88141ee 100644 --- a/cmd/internal/build/build.go +++ b/cmd/internal/build/build.go @@ -25,7 +25,7 @@ import ( "reflect" "github.com/goplus/gogen" - "github.com/goplus/gop" + "github.com/goplus/gop/tool" "github.com/goplus/gop/cl" "github.com/goplus/gop/cmd/internal/base" "github.com/goplus/gop/x/gocmd" @@ -74,9 +74,9 @@ func runCmd(cmd *base.Command, args []string) { log.Panicln("too many arguments:", args) } - conf, err := gop.NewDefaultConf(".", gop.ConfFlagNoTestFiles, pass.Tags()) + conf, err := tool.NewDefaultConf(".", tool.ConfFlagNoTestFiles, pass.Tags()) if err != nil { - log.Panicln("gop.NewDefaultConf:", err) + log.Panicln("tool.NewDefaultConf:", err) } defer conf.UpdateCache() @@ -92,23 +92,23 @@ func runCmd(cmd *base.Command, args []string) { build(proj, conf, confCmd) } -func build(proj gopprojs.Proj, conf *gop.Config, build *gocmd.BuildConfig) { - const flags = gop.GenFlagPrompt +func build(proj gopprojs.Proj, conf *tool.Config, build *gocmd.BuildConfig) { + const flags = tool.GenFlagPrompt var obj string var err error switch v := proj.(type) { case *gopprojs.DirProj: obj = v.Dir - err = gop.BuildDir(obj, conf, build, flags) + err = tool.BuildDir(obj, conf, build, flags) case *gopprojs.PkgPathProj: obj = v.Path - err = gop.BuildPkgPath("", v.Path, conf, build, flags) + err = tool.BuildPkgPath("", v.Path, conf, build, flags) case *gopprojs.FilesProj: - err = gop.BuildFiles(v.Files, conf, build) + err = tool.BuildFiles(v.Files, conf, build) default: log.Panicln("`gop build` doesn't support", reflect.TypeOf(v)) } - if gop.NotFound(err) { + if tool.NotFound(err) { fmt.Fprintf(os.Stderr, "gop build %v: not found\n", obj) } else if err != nil { fmt.Fprintln(os.Stderr, err) diff --git a/cmd/internal/doc/doc.go b/cmd/internal/doc/doc.go index 6c755e221..d9b3ef600 100644 --- a/cmd/internal/doc/doc.go +++ b/cmd/internal/doc/doc.go @@ -26,7 +26,7 @@ import ( "strings" "github.com/goplus/gogen" - "github.com/goplus/gop" + "github.com/goplus/gop/tool" "github.com/goplus/gop/cl" "github.com/goplus/gop/cl/outline" "github.com/goplus/gop/cmd/internal/base" @@ -76,25 +76,25 @@ func runCmd(cmd *base.Command, args []string) { } gopEnv := gopenv.Get() - conf := &gop.Config{Gop: gopEnv} + conf := &tool.Config{Gop: gopEnv} outlinePkg(proj, conf) } -func outlinePkg(proj gopprojs.Proj, conf *gop.Config) { +func outlinePkg(proj gopprojs.Proj, conf *tool.Config) { var obj string var out outline.Package var err error switch v := proj.(type) { case *gopprojs.DirProj: obj = v.Dir - out, err = gop.Outline(obj, conf) + out, err = tool.Outline(obj, conf) case *gopprojs.PkgPathProj: obj = v.Path - out, err = gop.OutlinePkgPath("", obj, conf, true) + out, err = tool.OutlinePkgPath("", obj, conf, true) default: log.Panicln("`gop doc` doesn't support", reflect.TypeOf(v)) } - if gop.NotFound(err) { + if tool.NotFound(err) { fmt.Fprintf(os.Stderr, "gop doc %v: not Go/Go+ files found\n", obj) } else if err != nil { fmt.Fprintln(os.Stderr, err) diff --git a/cmd/internal/gengo/go.go b/cmd/internal/gengo/go.go index 2fd5a5498..c35df89d0 100644 --- a/cmd/internal/gengo/go.go +++ b/cmd/internal/gengo/go.go @@ -24,7 +24,7 @@ import ( "reflect" "github.com/goplus/gogen" - "github.com/goplus/gop" + "github.com/goplus/gop/tool" "github.com/goplus/gop/cl" "github.com/goplus/gop/cmd/internal/base" "github.com/goplus/gop/x/gopprojs" @@ -72,30 +72,30 @@ func runCmd(cmd *base.Command, args []string) { cl.SetDisableRecover(true) } - conf, err := gop.NewDefaultConf(".", 0, *flagTags) + conf, err := tool.NewDefaultConf(".", 0, *flagTags) if err != nil { - log.Panicln("gop.NewDefaultConf:", err) + log.Panicln("tool.NewDefaultConf:", err) } defer conf.UpdateCache() - flags := gop.GenFlagPrintError | gop.GenFlagPrompt + flags := tool.GenFlagPrintError | tool.GenFlagPrompt if *flagCheckMode { - flags |= gop.GenFlagCheckOnly + flags |= tool.GenFlagCheckOnly if *flagIgnoreNotatedErr { conf.IgnoreNotatedError = true } } if *flagSingleMode { - flags |= gop.GenFlagSingleFile + flags |= tool.GenFlagSingleFile } for _, proj := range projs { switch v := proj.(type) { case *gopprojs.DirProj: - _, _, err = gop.GenGoEx(v.Dir, conf, true, flags) + _, _, err = tool.GenGoEx(v.Dir, conf, true, flags) case *gopprojs.PkgPathProj: - _, _, err = gop.GenGoPkgPathEx("", v.Path, conf, true, flags) + _, _, err = tool.GenGoPkgPathEx("", v.Path, conf, true, flags) case *gopprojs.FilesProj: - _, err = gop.GenGoFiles("", v.Files, conf) + _, err = tool.GenGoFiles("", v.Files, conf) default: log.Panicln("`gop go` doesn't support", reflect.TypeOf(v)) } diff --git a/cmd/internal/gopfmt/fmt.go b/cmd/internal/gopfmt/fmt.go index cab4619d5..debef34b2 100644 --- a/cmd/internal/gopfmt/fmt.go +++ b/cmd/internal/gopfmt/fmt.go @@ -26,8 +26,7 @@ import ( "path/filepath" "strings" - "github.com/goplus/gop" - + "github.com/goplus/gop/tool" "github.com/goplus/gop/cmd/internal/base" "github.com/goplus/gop/format" @@ -147,7 +146,7 @@ func (w *walker) walk(path string, d fs.DirEntry, err error) error { dir, _ := filepath.Split(path) fn, ok := w.dirMap[dir] if !ok { - if mod, err := gop.LoadMod(path); err == nil { + if mod, err := tool.LoadMod(path); err == nil { fn = func(ext string) (ok bool, class bool) { switch ext { case ".go", ".gop": diff --git a/cmd/internal/gopget/get.go b/cmd/internal/gopget/get.go index b9b6756a3..8616a867b 100644 --- a/cmd/internal/gopget/get.go +++ b/cmd/internal/gopget/get.go @@ -21,7 +21,7 @@ import ( "log" "os" - "github.com/goplus/gop" + "github.com/goplus/gop/tool" "github.com/goplus/gop/cmd/internal/base" "github.com/goplus/mod/modcache" "github.com/goplus/mod/modfetch" @@ -62,7 +62,7 @@ func runCmd(cmd *base.Command, args []string) { func get(pkgPath string) { modBase := "" mod, err := modload.Load(".") - noMod := gop.NotFound(err) + noMod := tool.NotFound(err) if !noMod { check(err) modBase = mod.Path() diff --git a/cmd/internal/install/install.go b/cmd/internal/install/install.go index 6f4aa2b9e..e7c2fbaf9 100644 --- a/cmd/internal/install/install.go +++ b/cmd/internal/install/install.go @@ -24,7 +24,7 @@ import ( "reflect" "github.com/goplus/gogen" - "github.com/goplus/gop" + "github.com/goplus/gop/tool" "github.com/goplus/gop/cl" "github.com/goplus/gop/cmd/internal/base" "github.com/goplus/gop/x/gocmd" @@ -71,9 +71,9 @@ func runCmd(cmd *base.Command, args []string) { cl.SetDisableRecover(true) } - conf, err := gop.NewDefaultConf(".", gop.ConfFlagNoTestFiles, pass.Tags()) + conf, err := tool.NewDefaultConf(".", tool.ConfFlagNoTestFiles, pass.Tags()) if err != nil { - log.Panicln("gop.NewDefaultConf:", err) + log.Panicln("tool.NewDefaultConf:", err) } defer conf.UpdateCache() @@ -84,23 +84,23 @@ func runCmd(cmd *base.Command, args []string) { } } -func install(proj gopprojs.Proj, conf *gop.Config, install *gocmd.InstallConfig) { - const flags = gop.GenFlagPrompt +func install(proj gopprojs.Proj, conf *tool.Config, install *gocmd.InstallConfig) { + const flags = tool.GenFlagPrompt var obj string var err error switch v := proj.(type) { case *gopprojs.DirProj: obj = v.Dir - err = gop.InstallDir(obj, conf, install, flags) + err = tool.InstallDir(obj, conf, install, flags) case *gopprojs.PkgPathProj: obj = v.Path - err = gop.InstallPkgPath("", v.Path, conf, install, flags) + err = tool.InstallPkgPath("", v.Path, conf, install, flags) case *gopprojs.FilesProj: - err = gop.InstallFiles(v.Files, conf, install) + err = tool.InstallFiles(v.Files, conf, install) default: log.Panicln("`gop install` doesn't support", reflect.TypeOf(v)) } - if gop.NotFound(err) { + if tool.NotFound(err) { fmt.Fprintf(os.Stderr, "gop install %v: not found\n", obj) } else if err != nil { fmt.Fprintln(os.Stderr, err) diff --git a/cmd/internal/mod/tidy.go b/cmd/internal/mod/tidy.go index 2a79d340e..c65e57268 100644 --- a/cmd/internal/mod/tidy.go +++ b/cmd/internal/mod/tidy.go @@ -20,7 +20,7 @@ import ( "fmt" "os" - "github.com/goplus/gop" + "github.com/goplus/gop/tool" "github.com/goplus/gop/cmd/internal/base" "github.com/goplus/gop/x/gopenv" ) @@ -36,9 +36,9 @@ func init() { } func runTidy(cmd *base.Command, args []string) { - err := gop.Tidy(".", gopenv.Get()) + err := tool.Tidy(".", gopenv.Get()) if err != nil { - if gop.NotFound(err) { + if tool.NotFound(err) { fmt.Fprintln(os.Stderr, "go.mod not found") } else { fmt.Fprintln(os.Stderr, err) diff --git a/cmd/internal/run/run.go b/cmd/internal/run/run.go index 6637af12a..9ede0a90c 100644 --- a/cmd/internal/run/run.go +++ b/cmd/internal/run/run.go @@ -23,7 +23,7 @@ import ( "reflect" "github.com/goplus/gogen" - "github.com/goplus/gop" + "github.com/goplus/gop/tool" "github.com/goplus/gop/cl" "github.com/goplus/gop/cmd/internal/base" "github.com/goplus/gop/x/gocmd" @@ -80,9 +80,9 @@ func runCmd(cmd *base.Command, args []string) { } noChdir := *flagNoChdir - conf, err := gop.NewDefaultConf(".", gop.ConfFlagNoTestFiles, pass.Tags()) + conf, err := tool.NewDefaultConf(".", tool.ConfFlagNoTestFiles, pass.Tags()) if err != nil { - log.Panicln("gop.NewDefaultConf:", err) + log.Panicln("tool.NewDefaultConf:", err) } defer conf.UpdateCache() @@ -94,23 +94,23 @@ func runCmd(cmd *base.Command, args []string) { run(proj, args, !noChdir, conf, confCmd) } -func run(proj gopprojs.Proj, args []string, chDir bool, conf *gop.Config, run *gocmd.RunConfig) { +func run(proj gopprojs.Proj, args []string, chDir bool, conf *tool.Config, run *gocmd.RunConfig) { const flags = 0 var obj string var err error switch v := proj.(type) { case *gopprojs.DirProj: obj = v.Dir - err = gop.RunDir(obj, args, conf, run, flags) + err = tool.RunDir(obj, args, conf, run, flags) case *gopprojs.PkgPathProj: obj = v.Path - err = gop.RunPkgPath(v.Path, args, chDir, conf, run, flags) + err = tool.RunPkgPath(v.Path, args, chDir, conf, run, flags) case *gopprojs.FilesProj: - err = gop.RunFiles("", v.Files, args, conf, run) + err = tool.RunFiles("", v.Files, args, conf, run) default: log.Panicln("`gop run` doesn't support", reflect.TypeOf(v)) } - if gop.NotFound(err) { + if tool.NotFound(err) { fmt.Fprintf(os.Stderr, "gop run %v: not found\n", obj) } else if err != nil { fmt.Fprintln(os.Stderr, err) diff --git a/cmd/internal/test/test.go b/cmd/internal/test/test.go index 7dd01cf9a..5f78610a6 100644 --- a/cmd/internal/test/test.go +++ b/cmd/internal/test/test.go @@ -24,7 +24,7 @@ import ( "reflect" "github.com/goplus/gogen" - "github.com/goplus/gop" + "github.com/goplus/gop/tool" "github.com/goplus/gop/cl" "github.com/goplus/gop/cmd/internal/base" "github.com/goplus/gop/x/gocmd" @@ -69,9 +69,9 @@ func runCmd(cmd *base.Command, args []string) { cl.SetDisableRecover(true) } - conf, err := gop.NewDefaultConf(".", 0, pass.Tags()) + conf, err := tool.NewDefaultConf(".", 0, pass.Tags()) if err != nil { - log.Panicln("gop.NewDefaultConf:", err) + log.Panicln("tool.NewDefaultConf:", err) } defer conf.UpdateCache() @@ -82,23 +82,23 @@ func runCmd(cmd *base.Command, args []string) { } } -func test(proj gopprojs.Proj, conf *gop.Config, test *gocmd.TestConfig) { - const flags = gop.GenFlagPrompt +func test(proj gopprojs.Proj, conf *tool.Config, test *gocmd.TestConfig) { + const flags = tool.GenFlagPrompt var obj string var err error switch v := proj.(type) { case *gopprojs.DirProj: obj = v.Dir - err = gop.TestDir(obj, conf, test, flags) + err = tool.TestDir(obj, conf, test, flags) case *gopprojs.PkgPathProj: obj = v.Path - err = gop.TestPkgPath("", v.Path, conf, test, flags) + err = tool.TestPkgPath("", v.Path, conf, test, flags) case *gopprojs.FilesProj: - err = gop.TestFiles(v.Files, conf, test) + err = tool.TestFiles(v.Files, conf, test) default: log.Panicln("`gop test` doesn't support", reflect.TypeOf(v)) } - if gop.NotFound(err) { + if tool.NotFound(err) { fmt.Fprintf(os.Stderr, "gop test %v: not found\n", obj) } else if err != nil { fmt.Fprintln(os.Stderr, err) diff --git a/cmd/internal/watch/watch.go b/cmd/internal/watch/watch.go index 32b2b022d..3fca3cbf6 100644 --- a/cmd/internal/watch/watch.go +++ b/cmd/internal/watch/watch.go @@ -20,7 +20,7 @@ import ( "log" "path/filepath" - "github.com/goplus/gop" + "github.com/goplus/gop/tool" "github.com/goplus/gop/cmd/internal/base" "github.com/goplus/gop/x/fsnotify" "github.com/goplus/gop/x/watcher" @@ -70,7 +70,7 @@ func runCmd(cmd *base.Command, args []string) { for { dir := w.Fetch(true) log.Println("GenGo", dir) - _, _, err := gop.GenGo(dir, nil, *genTestPkg) + _, _, err := tool.GenGo(dir, nil, *genTestPkg) if err != nil { log.Println(err) } diff --git a/_gendeps.go b/tool/_gendeps.go similarity index 99% rename from _gendeps.go rename to tool/_gendeps.go index 1c80fc294..7a2c43896 100644 --- a/_gendeps.go +++ b/tool/_gendeps.go @@ -14,7 +14,7 @@ * limitations under the License. */ -package gop +package tool import ( "fmt" diff --git a/build_install_run.go b/tool/build_install_run.go similarity index 88% rename from build_install_run.go rename to tool/build_install_run.go index b0c6d138c..1f66f2d91 100644 --- a/build_install_run.go +++ b/tool/build_install_run.go @@ -14,7 +14,7 @@ * limitations under the License. */ -package gop +package tool import ( "log" @@ -37,7 +37,7 @@ func genFlags(flags []GenFlags) GenFlags { func InstallDir(dir string, conf *Config, install *gocmd.InstallConfig, flags ...GenFlags) (err error) { _, _, err = GenGoEx(dir, conf, false, genFlags(flags)) if err != nil { - return errors.NewWith(err, `GenGo(dir, conf, false)`, -2, "gop.GenGo", dir, conf, false) + return errors.NewWith(err, `GenGo(dir, conf, false)`, -2, "tool.GenGo", dir, conf, false) } return gocmd.Install(dir, install) } @@ -46,7 +46,7 @@ func InstallDir(dir string, conf *Config, install *gocmd.InstallConfig, flags .. func InstallPkgPath(workDir, pkgPath string, conf *Config, install *gocmd.InstallConfig, flags ...GenFlags) (err error) { localDir, recursively, err := GenGoPkgPathEx(workDir, pkgPath, conf, true, genFlags(flags)) if err != nil { - return errors.NewWith(err, `GenGoPkgPath(workDir, pkgPath, conf, true)`, -2, "gop.GenGoPkgPath", workDir, pkgPath, conf, true) + return errors.NewWith(err, `GenGoPkgPath(workDir, pkgPath, conf, true)`, -2, "tool.GenGoPkgPath", workDir, pkgPath, conf, true) } old := chdir(localDir) defer os.Chdir(old) @@ -64,7 +64,7 @@ func cwdParam(recursively bool) string { func InstallFiles(files []string, conf *Config, install *gocmd.InstallConfig) (err error) { files, err = GenGoFiles("", files, conf) if err != nil { - return errors.NewWith(err, `GenGoFiles("", files, conf)`, -2, "gop.GenGoFiles", "", files, conf) + return errors.NewWith(err, `GenGoFiles("", files, conf)`, -2, "tool.GenGoFiles", "", files, conf) } return gocmd.InstallFiles(files, install) } @@ -87,7 +87,7 @@ func chdir(dir string) string { func BuildDir(dir string, conf *Config, build *gocmd.BuildConfig, flags ...GenFlags) (err error) { _, _, err = GenGoEx(dir, conf, false, genFlags(flags)) if err != nil { - return errors.NewWith(err, `GenGo(dir, conf, false)`, -2, "gop.GenGo", dir, conf, false) + return errors.NewWith(err, `GenGo(dir, conf, false)`, -2, "tool.GenGo", dir, conf, false) } return gocmd.Build(dir, build) } @@ -96,7 +96,7 @@ func BuildDir(dir string, conf *Config, build *gocmd.BuildConfig, flags ...GenFl func BuildPkgPath(workDir, pkgPath string, conf *Config, build *gocmd.BuildConfig, flags ...GenFlags) (err error) { localDir, recursively, err := GenGoPkgPathEx(workDir, pkgPath, conf, false, genFlags(flags)) if err != nil { - return errors.NewWith(err, `GenGoPkgPath(workDir, pkgPath, conf, false)`, -2, "gop.GenGoPkgPath", workDir, pkgPath, conf, false) + return errors.NewWith(err, `GenGoPkgPath(workDir, pkgPath, conf, false)`, -2, "tool.GenGoPkgPath", workDir, pkgPath, conf, false) } old, mod := chdirAndMod(localDir) defer restoreDirAndMod(old, mod) @@ -107,7 +107,7 @@ func BuildPkgPath(workDir, pkgPath string, conf *Config, build *gocmd.BuildConfi func BuildFiles(files []string, conf *Config, build *gocmd.BuildConfig) (err error) { files, err = GenGoFiles("", files, conf) if err != nil { - return errors.NewWith(err, `GenGoFiles("", files, conf)`, -2, "gop.GenGoFiles", "", files, conf) + return errors.NewWith(err, `GenGoFiles("", files, conf)`, -2, "tool.GenGoFiles", "", files, conf) } return gocmd.BuildFiles(files, build) } @@ -141,7 +141,7 @@ func getBuildDir(conf *Config) string { func RunDir(dir string, args []string, conf *Config, run *gocmd.RunConfig, flags ...GenFlags) (err error) { _, _, err = GenGoEx(dir, conf, false, genFlags(flags)) if err != nil { - return errors.NewWith(err, `GenGo(dir, conf, false)`, -2, "gop.GenGo", dir, conf, false) + return errors.NewWith(err, `GenGo(dir, conf, false)`, -2, "tool.GenGo", dir, conf, false) } return gocmd.RunDir(getBuildDir(conf), dir, args, run) } @@ -150,7 +150,7 @@ func RunDir(dir string, args []string, conf *Config, run *gocmd.RunConfig, flags func RunPkgPath(pkgPath string, args []string, chDir bool, conf *Config, run *gocmd.RunConfig, flags ...GenFlags) (err error) { localDir, recursively, err := GenGoPkgPathEx("", pkgPath, conf, true, genFlags(flags)) if err != nil { - return errors.NewWith(err, `GenGoPkgPath("", pkgPath, conf, true)`, -2, "gop.GenGoPkgPath", "", pkgPath, conf, true) + return errors.NewWith(err, `GenGoPkgPath("", pkgPath, conf, true)`, -2, "tool.GenGoPkgPath", "", pkgPath, conf, true) } if recursively { return errors.NewWith(errors.New("can't use ... pattern for `gop run` command"), `recursively`, -1, "", recursively) @@ -167,7 +167,7 @@ func RunPkgPath(pkgPath string, args []string, chDir bool, conf *Config, run *go func RunFiles(autogen string, files []string, args []string, conf *Config, run *gocmd.RunConfig) (err error) { files, err = GenGoFiles(autogen, files, conf) if err != nil { - return errors.NewWith(err, `GenGoFiles(autogen, files, conf)`, -2, "gop.GenGoFiles", autogen, files, conf) + return errors.NewWith(err, `GenGoFiles(autogen, files, conf)`, -2, "tool.GenGoFiles", autogen, files, conf) } return gocmd.RunFiles(getBuildDir(conf), files, args, run) } @@ -178,7 +178,7 @@ func RunFiles(autogen string, files []string, args []string, conf *Config, run * func TestDir(dir string, conf *Config, test *gocmd.TestConfig, flags ...GenFlags) (err error) { _, _, err = GenGoEx(dir, conf, true, genFlags(flags)) if err != nil { - return errors.NewWith(err, `GenGo(dir, conf, true)`, -2, "gop.GenGo", dir, conf, true) + return errors.NewWith(err, `GenGo(dir, conf, true)`, -2, "tool.GenGo", dir, conf, true) } return gocmd.Test(dir, test) } @@ -187,7 +187,7 @@ func TestDir(dir string, conf *Config, test *gocmd.TestConfig, flags ...GenFlags func TestPkgPath(workDir, pkgPath string, conf *Config, test *gocmd.TestConfig, flags ...GenFlags) (err error) { localDir, recursively, err := GenGoPkgPathEx(workDir, pkgPath, conf, false, genFlags(flags)) if err != nil { - return errors.NewWith(err, `GenGoPkgPath(workDir, pkgPath, conf, false)`, -2, "gop.GenGoPkgPath", workDir, pkgPath, conf, false) + return errors.NewWith(err, `GenGoPkgPath(workDir, pkgPath, conf, false)`, -2, "tool.GenGoPkgPath", workDir, pkgPath, conf, false) } old, mod := chdirAndMod(localDir) defer restoreDirAndMod(old, mod) @@ -198,7 +198,7 @@ func TestPkgPath(workDir, pkgPath string, conf *Config, test *gocmd.TestConfig, func TestFiles(files []string, conf *Config, test *gocmd.TestConfig) (err error) { files, err = GenGoFiles("", files, conf) if err != nil { - return errors.NewWith(err, `GenGoFiles("", files, conf)`, -2, "gop.GenGoFiles", "", files, conf) + return errors.NewWith(err, `GenGoFiles("", files, conf)`, -2, "tool.GenGoFiles", "", files, conf) } return gocmd.TestFiles(files, test) } diff --git a/gengo.go b/tool/gengo.go similarity index 97% rename from gengo.go rename to tool/gengo.go index 336bf21ec..2d0911174 100644 --- a/gengo.go +++ b/tool/gengo.go @@ -14,7 +14,7 @@ * limitations under the License. */ -package gop +package tool import ( "fmt" @@ -154,7 +154,7 @@ func genGoSingleFile(file string, conf *Config, flags GenFlags) (err error) { } out, err := LoadFiles(".", []string{file}, conf) if err != nil { - return errors.NewWith(err, `LoadFiles(files, conf)`, -2, "gop.LoadFiles", file) + return errors.NewWith(err, `LoadFiles(files, conf)`, -2, "tool.LoadFiles", file) } if flags&GenFlagCheckOnly != 0 { return nil @@ -171,7 +171,7 @@ func genGoIn(dir string, conf *Config, genTestPkg bool, flags GenFlags, gen ...* if NotFound(err) { // no Go+ source files return nil } - return errors.NewWith(err, `LoadDir(dir, conf, genTestPkg)`, -5, "gop.LoadDir", dir, conf, genTestPkg) + return errors.NewWith(err, `LoadDir(dir, conf, genTestPkg)`, -5, "tool.LoadDir", dir, conf, genTestPkg) } if flags&GenFlagCheckOnly != 0 { return nil @@ -288,7 +288,7 @@ func GenGoFiles(autogen string, files []string, conf *Config) (outFiles []string } out, err := LoadFiles(".", files, conf) if err != nil { - err = errors.NewWith(err, `LoadFiles(files, conf)`, -2, "gop.LoadFiles", files, conf) + err = errors.NewWith(err, `LoadFiles(files, conf)`, -2, "tool.LoadFiles", files, conf) return } err = out.WriteFile(autogen) diff --git a/imp.go b/tool/imp.go similarity index 99% rename from imp.go rename to tool/imp.go index f7360c529..6c7c32391 100644 --- a/imp.go +++ b/tool/imp.go @@ -14,7 +14,7 @@ * limitations under the License. */ -package gop +package tool import ( "crypto/sha256" diff --git a/load.go b/tool/load.go similarity index 98% rename from load.go rename to tool/load.go index f6728c55b..185bee9cf 100644 --- a/load.go +++ b/tool/load.go @@ -14,7 +14,7 @@ * limitations under the License. */ -package gop +package tool import ( "fmt" @@ -238,7 +238,7 @@ func LoadDir(dir string, conf *Config, genTestPkg bool, promptGenGo ...bool) (ou mod := conf.Mod if mod == nil { if mod, err = LoadMod(dir); err != nil { - err = errors.NewWith(err, `LoadMod(dir)`, -2, "gop.LoadMod", dir) + err = errors.NewWith(err, `LoadMod(dir)`, -2, "tool.LoadMod", dir) return } } @@ -358,7 +358,7 @@ func LoadFiles(dir string, files []string, conf *Config) (out *gogen.Package, er mod := conf.Mod if mod == nil { if mod, err = LoadMod(dir); err != nil { - err = errors.NewWith(err, `LoadMod(dir)`, -2, "gop.LoadMod", dir) + err = errors.NewWith(err, `LoadMod(dir)`, -2, "tool.LoadMod", dir) return } } diff --git a/outline.go b/tool/outline.go similarity index 95% rename from outline.go rename to tool/outline.go index 99b059ff5..8b0b4b369 100644 --- a/outline.go +++ b/tool/outline.go @@ -14,7 +14,7 @@ * limitations under the License. */ -package gop +package tool import ( "fmt" @@ -46,7 +46,7 @@ func Outline(dir string, conf *Config) (out outline.Package, err error) { mod := conf.Mod if mod == nil { if mod, err = LoadMod(dir); err != nil { - err = errors.NewWith(err, `LoadMod(dir)`, -2, "gop.LoadMod", dir) + err = errors.NewWith(err, `LoadMod(dir)`, -2, "tool.LoadMod", dir) return } } @@ -119,7 +119,7 @@ func OutlinePkgPath(workDir, pkgPath string, conf *Config, allowExtern bool) (ou mod := conf.Mod if mod == nil { if mod, err = LoadMod(workDir); err != nil { - err = errors.NewWith(err, `LoadMod(dir)`, -2, "gop.LoadMod", workDir) + err = errors.NewWith(err, `LoadMod(dir)`, -2, "tool.LoadMod", workDir) return } } diff --git a/tidy.go b/tool/tidy.go similarity index 94% rename from tidy.go rename to tool/tidy.go index 1e2f2c118..7df723760 100644 --- a/tidy.go +++ b/tool/tidy.go @@ -14,7 +14,7 @@ * limitations under the License. */ -package gop +package tool import ( "os" @@ -35,7 +35,7 @@ func Tidy(dir string, gop *env.Gop) (err error) { /* depMods, err := GenDepMods(modObj, modRoot, true) if err != nil { - return errors.NewWith(err, `GenDepMods(modObj, modRoot, true)`, -2, "gop.GenDepMods", modObj, modRoot, true) + return errors.NewWith(err, `GenDepMods(modObj, modRoot, true)`, -2, "tool.GenDepMods", modObj, modRoot, true) } old := modObj.DepMods() @@ -63,7 +63,7 @@ func Tidy(dir string, gop *env.Gop) (err error) { conf := &Config{Gop: gop} err = genGoDir(modRoot, conf, true, true, 0) if err != nil { - return errors.NewWith(err, `genGoDir(modRoot, conf, true, true)`, -2, "gop.genGoDir", modRoot, conf, true, true) + return errors.NewWith(err, `genGoDir(modRoot, conf, true, true)`, -2, "tool.genGoDir", modRoot, conf, true, true) } cmd := exec.Command("go", "mod", "tidy") diff --git a/x/langserver/server.go b/x/langserver/server.go index 1e26e6be7..47de37cbc 100644 --- a/x/langserver/server.go +++ b/x/langserver/server.go @@ -23,7 +23,7 @@ import ( "sync" "time" - "github.com/goplus/gop" + "github.com/goplus/gop/tool" "github.com/goplus/gop/x/gopprojs" "github.com/goplus/gop/x/jsonrpc2" ) @@ -99,7 +99,7 @@ func (p *handler) runLoop() { time.Sleep(duration) continue } - gop.GenGoEx(dir, nil, true, gop.GenFlagPrompt) + tool.GenGoEx(dir, nil, true, tool.GenFlagPrompt) } } @@ -138,19 +138,19 @@ func GenGo(pattern ...string) (err error) { if err != nil { return } - conf, _ := gop.NewDefaultConf(".", 0) + conf, _ := tool.NewDefaultConf(".", 0) if conf != nil { defer conf.UpdateCache() } for _, proj := range projs { switch v := proj.(type) { case *gopprojs.DirProj: - gop.GenGoEx(v.Dir, conf, true, 0) + tool.GenGoEx(v.Dir, conf, true, 0) case *gopprojs.PkgPathProj: if v.Path == "builtin" { continue } - gop.GenGoPkgPathEx("", v.Path, conf, true, 0) + tool.GenGoPkgPathEx("", v.Path, conf, true, 0) } } return From d31ec737d9fce4328ac355db3561df12122cc5b5 Mon Sep 17 00:00:00 2001 From: xushiwei Date: Mon, 13 Jan 2025 22:12:50 +0800 Subject: [PATCH 2/5] codecov.yml: ignore tool --- .github/codecov.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/codecov.yml b/.github/codecov.yml index 1c0977ddf..0752ec08f 100644 --- a/.github/codecov.yml +++ b/.github/codecov.yml @@ -27,4 +27,5 @@ coverage: - "x/typesutil" - "x/gocmd" - "x/gopenv" + - "tool" \ No newline at end of file From 5c48320a6c8dece83f6c51fa3ab5c3cbb6e91b30 Mon Sep 17 00:00:00 2001 From: xushiwei Date: Mon, 13 Jan 2025 22:17:39 +0800 Subject: [PATCH 3/5] .goreleaser.yaml: mv *.go => tool --- .goreleaser.yaml | 32 ++++---------------------------- 1 file changed, 4 insertions(+), 28 deletions(-) diff --git a/.goreleaser.yaml b/.goreleaser.yaml index 2553aacc2..fda1cbbb3 100644 --- a/.goreleaser.yaml +++ b/.goreleaser.yaml @@ -185,16 +185,14 @@ nfpms: dst: "/usr/lib/{{ .ProjectName }}/Makefile" - src: "README.md" dst: "/usr/lib/{{ .ProjectName }}/README.md" - - src: "_gendeps.go" - dst: "/usr/lib/{{ .ProjectName }}/_gendeps.go" - src: "all.bash" dst: "/usr/lib/{{ .ProjectName }}/all.bash" - src: "all.bat" dst: "/usr/lib/{{ .ProjectName }}/all.bat" - src: "ast" dst: "/usr/lib/{{ .ProjectName }}/ast" - - src: "build_install_run.go" - dst: "/usr/lib/{{ .ProjectName }}/build_install_run.go" + - src: "tool" + dst: "/usr/lib/{{ .ProjectName }}/tool" - src: "builtin" dst: "/usr/lib/{{ .ProjectName }}/builtin" - src: "cl" @@ -207,22 +205,14 @@ nfpms: dst: "/usr/lib/{{ .ProjectName }}/env" - src: "format" dst: "/usr/lib/{{ .ProjectName }}/format" - - src: "gengo.go" - dst: "/usr/lib/{{ .ProjectName }}/gengo.go" - src: "go.mod" dst: "/usr/lib/{{ .ProjectName }}/go.mod" - src: "go.sum" dst: "/usr/lib/{{ .ProjectName }}/go.sum" - - src: "imp.go" - dst: "/usr/lib/{{ .ProjectName }}/imp.go" - - src: "load.go" - dst: "/usr/lib/{{ .ProjectName }}/load.go" - src: "make.bash" dst: "/usr/lib/{{ .ProjectName }}/make.bash" - src: "make.bat" dst: "/usr/lib/{{ .ProjectName }}/make.bat" - - src: "outline.go" - dst: "/usr/lib/{{ .ProjectName }}/outline.go" - src: "parser" dst: "/usr/lib/{{ .ProjectName }}/parser" - src: "printer" @@ -233,8 +223,6 @@ nfpms: dst: "/usr/lib/{{ .ProjectName }}/test" - src: "demo" dst: "/usr/lib/{{ .ProjectName }}/demo" - - src: "tidy.go" - dst: "/usr/lib/{{ .ProjectName }}/tidy.go" - src: "token" dst: "/usr/lib/{{ .ProjectName }}/token" - src: "x" @@ -271,16 +259,14 @@ snapcrafts: destination: "Makefile" - source: "README.md" destination: "README.md" - - source: "_gendeps.go" - destination: "_gendeps.go" - source: "all.bash" destination: "all.bash" - source: "all.bat" destination: "all.bat" - source: "ast" destination: "ast" - - source: "build_install_run.go" - destination: "build_install_run.go" + - source: "tool" + destination: "tool" - source: "builtin" destination: "builtin" - source: "cl" @@ -293,22 +279,14 @@ snapcrafts: destination: "env" - source: "format" destination: "format" - - source: "gengo.go" - destination: "gengo.go" - source: "go.mod" destination: "go.mod" - source: "go.sum" destination: "go.sum" - - source: "imp.go" - destination: "imp.go" - - source: "load.go" - destination: "load.go" - source: "make.bash" destination: "make.bash" - source: "make.bat" destination: "make.bat" - - source: "outline.go" - destination: "outline.go" - source: "parser" destination: "parser" - source: "printer" @@ -319,8 +297,6 @@ snapcrafts: destination: "test" - source: "demo" destination: "demo" - - source: "tidy.go" - destination: "tidy.go" - source: "token" destination: "token" - source: "x" From 272e260741f9b689c55838a9bbcde9bcf4d1543c Mon Sep 17 00:00:00 2001 From: xushiwei Date: Mon, 13 Jan 2025 22:18:41 +0800 Subject: [PATCH 4/5] gofmt --- cmd/chore/gopfmt/gopfmt.go | 2 +- cmd/internal/build/build.go | 2 +- cmd/internal/doc/doc.go | 2 +- cmd/internal/gengo/go.go | 2 +- cmd/internal/gopfmt/fmt.go | 2 +- cmd/internal/gopget/get.go | 2 +- cmd/internal/install/install.go | 2 +- cmd/internal/mod/tidy.go | 2 +- cmd/internal/run/run.go | 2 +- cmd/internal/test/test.go | 2 +- cmd/internal/watch/watch.go | 2 +- 11 files changed, 11 insertions(+), 11 deletions(-) diff --git a/cmd/chore/gopfmt/gopfmt.go b/cmd/chore/gopfmt/gopfmt.go index 48f81ef93..cb1ad300e 100644 --- a/cmd/chore/gopfmt/gopfmt.go +++ b/cmd/chore/gopfmt/gopfmt.go @@ -30,8 +30,8 @@ import ( goformat "go/format" - "github.com/goplus/gop/tool" "github.com/goplus/gop/format" + "github.com/goplus/gop/tool" ) var ( diff --git a/cmd/internal/build/build.go b/cmd/internal/build/build.go index 8d88141ee..b73eea996 100644 --- a/cmd/internal/build/build.go +++ b/cmd/internal/build/build.go @@ -25,9 +25,9 @@ import ( "reflect" "github.com/goplus/gogen" - "github.com/goplus/gop/tool" "github.com/goplus/gop/cl" "github.com/goplus/gop/cmd/internal/base" + "github.com/goplus/gop/tool" "github.com/goplus/gop/x/gocmd" "github.com/goplus/gop/x/gopprojs" ) diff --git a/cmd/internal/doc/doc.go b/cmd/internal/doc/doc.go index d9b3ef600..e3f7d3065 100644 --- a/cmd/internal/doc/doc.go +++ b/cmd/internal/doc/doc.go @@ -26,10 +26,10 @@ import ( "strings" "github.com/goplus/gogen" - "github.com/goplus/gop/tool" "github.com/goplus/gop/cl" "github.com/goplus/gop/cl/outline" "github.com/goplus/gop/cmd/internal/base" + "github.com/goplus/gop/tool" "github.com/goplus/gop/x/gopenv" "github.com/goplus/gop/x/gopprojs" ) diff --git a/cmd/internal/gengo/go.go b/cmd/internal/gengo/go.go index c35df89d0..31c64145b 100644 --- a/cmd/internal/gengo/go.go +++ b/cmd/internal/gengo/go.go @@ -24,9 +24,9 @@ import ( "reflect" "github.com/goplus/gogen" - "github.com/goplus/gop/tool" "github.com/goplus/gop/cl" "github.com/goplus/gop/cmd/internal/base" + "github.com/goplus/gop/tool" "github.com/goplus/gop/x/gopprojs" "github.com/qiniu/x/errors" ) diff --git a/cmd/internal/gopfmt/fmt.go b/cmd/internal/gopfmt/fmt.go index debef34b2..1cf792da0 100644 --- a/cmd/internal/gopfmt/fmt.go +++ b/cmd/internal/gopfmt/fmt.go @@ -26,9 +26,9 @@ import ( "path/filepath" "strings" - "github.com/goplus/gop/tool" "github.com/goplus/gop/cmd/internal/base" "github.com/goplus/gop/format" + "github.com/goplus/gop/tool" goformat "go/format" "go/parser" diff --git a/cmd/internal/gopget/get.go b/cmd/internal/gopget/get.go index 8616a867b..0cff04a7c 100644 --- a/cmd/internal/gopget/get.go +++ b/cmd/internal/gopget/get.go @@ -21,8 +21,8 @@ import ( "log" "os" - "github.com/goplus/gop/tool" "github.com/goplus/gop/cmd/internal/base" + "github.com/goplus/gop/tool" "github.com/goplus/mod/modcache" "github.com/goplus/mod/modfetch" "github.com/goplus/mod/modload" diff --git a/cmd/internal/install/install.go b/cmd/internal/install/install.go index e7c2fbaf9..9639faa64 100644 --- a/cmd/internal/install/install.go +++ b/cmd/internal/install/install.go @@ -24,9 +24,9 @@ import ( "reflect" "github.com/goplus/gogen" - "github.com/goplus/gop/tool" "github.com/goplus/gop/cl" "github.com/goplus/gop/cmd/internal/base" + "github.com/goplus/gop/tool" "github.com/goplus/gop/x/gocmd" "github.com/goplus/gop/x/gopprojs" "github.com/goplus/mod/modfetch" diff --git a/cmd/internal/mod/tidy.go b/cmd/internal/mod/tidy.go index c65e57268..a40ce2537 100644 --- a/cmd/internal/mod/tidy.go +++ b/cmd/internal/mod/tidy.go @@ -20,8 +20,8 @@ import ( "fmt" "os" - "github.com/goplus/gop/tool" "github.com/goplus/gop/cmd/internal/base" + "github.com/goplus/gop/tool" "github.com/goplus/gop/x/gopenv" ) diff --git a/cmd/internal/run/run.go b/cmd/internal/run/run.go index 9ede0a90c..8b01293e6 100644 --- a/cmd/internal/run/run.go +++ b/cmd/internal/run/run.go @@ -23,9 +23,9 @@ import ( "reflect" "github.com/goplus/gogen" - "github.com/goplus/gop/tool" "github.com/goplus/gop/cl" "github.com/goplus/gop/cmd/internal/base" + "github.com/goplus/gop/tool" "github.com/goplus/gop/x/gocmd" "github.com/goplus/gop/x/gopprojs" "github.com/qiniu/x/log" diff --git a/cmd/internal/test/test.go b/cmd/internal/test/test.go index 5f78610a6..add1de0b2 100644 --- a/cmd/internal/test/test.go +++ b/cmd/internal/test/test.go @@ -24,9 +24,9 @@ import ( "reflect" "github.com/goplus/gogen" - "github.com/goplus/gop/tool" "github.com/goplus/gop/cl" "github.com/goplus/gop/cmd/internal/base" + "github.com/goplus/gop/tool" "github.com/goplus/gop/x/gocmd" "github.com/goplus/gop/x/gopprojs" ) diff --git a/cmd/internal/watch/watch.go b/cmd/internal/watch/watch.go index 3fca3cbf6..b753052ff 100644 --- a/cmd/internal/watch/watch.go +++ b/cmd/internal/watch/watch.go @@ -20,8 +20,8 @@ import ( "log" "path/filepath" - "github.com/goplus/gop/tool" "github.com/goplus/gop/cmd/internal/base" + "github.com/goplus/gop/tool" "github.com/goplus/gop/x/fsnotify" "github.com/goplus/gop/x/watcher" ) From bb8760c18eea4c13bad5717b4d99d14f0829bddf Mon Sep 17 00:00:00 2001 From: xushiwei Date: Mon, 13 Jan 2025 22:27:52 +0800 Subject: [PATCH 5/5] mv *.go => tool --- cl/cltest/cltest.go | 4 ++-- cl/typeparams_test.go | 16 ++++++++++++++++ x/typesutil/info_test.go | 4 ++-- 3 files changed, 20 insertions(+), 4 deletions(-) diff --git a/cl/cltest/cltest.go b/cl/cltest/cltest.go index a2c7f3e9d..013908ca0 100644 --- a/cl/cltest/cltest.go +++ b/cl/cltest/cltest.go @@ -26,13 +26,13 @@ import ( "testing" "github.com/goplus/gogen" - "github.com/goplus/gop" "github.com/goplus/gop/cl" "github.com/goplus/gop/parser" "github.com/goplus/gop/parser/fsx" "github.com/goplus/gop/parser/fsx/memfs" "github.com/goplus/gop/scanner" "github.com/goplus/gop/token" + "github.com/goplus/gop/tool" "github.com/goplus/mod/env" "github.com/goplus/mod/modfile" ) @@ -47,7 +47,7 @@ func init() { gogen.SetDebug(gogen.DbgFlagAll) cl.SetDebug(cl.DbgFlagAll | cl.FlagNoMarkAutogen) fset := token.NewFileSet() - imp := gop.NewImporter(nil, Gop, fset) + imp := tool.NewImporter(nil, Gop, fset) Conf = &cl.Config{ Fset: fset, Importer: imp, diff --git a/cl/typeparams_test.go b/cl/typeparams_test.go index 40a079d37..b1a679e0e 100644 --- a/cl/typeparams_test.go +++ b/cl/typeparams_test.go @@ -1,3 +1,19 @@ +/* + * Copyright (c) 2022 The GoPlus Authors (goplus.org). All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package cl_test import ( diff --git a/x/typesutil/info_test.go b/x/typesutil/info_test.go index ef1ca10e2..5f34a42b9 100644 --- a/x/typesutil/info_test.go +++ b/x/typesutil/info_test.go @@ -16,11 +16,11 @@ import ( "unsafe" "github.com/goplus/gogen" - "github.com/goplus/gop" "github.com/goplus/gop/ast" "github.com/goplus/gop/format" "github.com/goplus/gop/parser" "github.com/goplus/gop/token" + "github.com/goplus/gop/tool" "github.com/goplus/gop/x/typesutil" "github.com/goplus/mod/env" "github.com/goplus/mod/gopmod" @@ -77,7 +77,7 @@ func parseMixedSource(mod *gopmod.Module, fset *token.FileSet, name, src string, } conf := &types.Config{} - conf.Importer = gop.NewImporter(nil, &env.Gop{Root: "../..", Version: "1.0"}, fset) + conf.Importer = tool.NewImporter(nil, &env.Gop{Root: "../..", Version: "1.0"}, fset) chkOpts := &typesutil.Config{ Types: types.NewPackage("main", f.Name.Name), Fset: fset,