Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mv *.go => tool/*.go #2080

Merged
merged 5 commits into from
Jan 13, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,5 @@ coverage:
- "x/typesutil"
- "x/gocmd"
- "x/gopenv"
- "tool"

32 changes: 4 additions & 28 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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"
Expand All @@ -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"
Expand Down Expand Up @@ -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"
Expand All @@ -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"
Expand All @@ -319,8 +297,6 @@ snapcrafts:
destination: "test"
- source: "demo"
destination: "demo"
- source: "tidy.go"
destination: "tidy.go"
- source: "token"
destination: "token"
- source: "x"
Expand Down
4 changes: 2 additions & 2 deletions cl/cltest/cltest.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand All @@ -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,
Expand Down
16 changes: 16 additions & 0 deletions cl/typeparams_test.go
Original file line number Diff line number Diff line change
@@ -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 (
Expand Down
4 changes: 2 additions & 2 deletions cmd/chore/gopfmt/gopfmt.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ import (

goformat "go/format"

"github.com/goplus/gop"
"github.com/goplus/gop/format"
"github.com/goplus/gop/tool"
)

var (
Expand Down Expand Up @@ -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":
Expand Down
6 changes: 3 additions & 3 deletions cmd/chore/goptestgo/goptestgo.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand All @@ -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 {
Expand All @@ -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) {
Expand Down
18 changes: 9 additions & 9 deletions cmd/internal/build/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ import (
"reflect"

"github.com/goplus/gogen"
"github.com/goplus/gop"
"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"
)
Expand Down Expand Up @@ -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()

Expand All @@ -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)
Expand Down
12 changes: 6 additions & 6 deletions cmd/internal/doc/doc.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ import (
"strings"

"github.com/goplus/gogen"
"github.com/goplus/gop"
"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"
)
Expand Down Expand Up @@ -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)
Expand Down
18 changes: 9 additions & 9 deletions cmd/internal/gengo/go.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ import (
"reflect"

"github.com/goplus/gogen"
"github.com/goplus/gop"
"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"
)
Expand Down Expand Up @@ -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))
}
Expand Down
5 changes: 2 additions & 3 deletions cmd/internal/gopfmt/fmt.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,9 @@ import (
"path/filepath"
"strings"

"github.com/goplus/gop"

"github.com/goplus/gop/cmd/internal/base"
"github.com/goplus/gop/format"
"github.com/goplus/gop/tool"

goformat "go/format"
"go/parser"
Expand Down Expand Up @@ -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":
Expand Down
4 changes: 2 additions & 2 deletions cmd/internal/gopget/get.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ import (
"log"
"os"

"github.com/goplus/gop"
"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"
Expand Down Expand Up @@ -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()
Expand Down
Loading
Loading