Skip to content

Commit 69556ad

Browse files
authored
Merge pull request #2080 from xushiwei/q
mv *.go => tool/*.go
2 parents f54a3eb + bb8760c commit 69556ad

File tree

25 files changed

+122
-130
lines changed

25 files changed

+122
-130
lines changed

.github/codecov.yml

+1
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,5 @@ coverage:
2727
- "x/typesutil"
2828
- "x/gocmd"
2929
- "x/gopenv"
30+
- "tool"
3031

.goreleaser.yaml

+4-28
Original file line numberDiff line numberDiff line change
@@ -185,16 +185,14 @@ nfpms:
185185
dst: "/usr/lib/{{ .ProjectName }}/Makefile"
186186
- src: "README.md"
187187
dst: "/usr/lib/{{ .ProjectName }}/README.md"
188-
- src: "_gendeps.go"
189-
dst: "/usr/lib/{{ .ProjectName }}/_gendeps.go"
190188
- src: "all.bash"
191189
dst: "/usr/lib/{{ .ProjectName }}/all.bash"
192190
- src: "all.bat"
193191
dst: "/usr/lib/{{ .ProjectName }}/all.bat"
194192
- src: "ast"
195193
dst: "/usr/lib/{{ .ProjectName }}/ast"
196-
- src: "build_install_run.go"
197-
dst: "/usr/lib/{{ .ProjectName }}/build_install_run.go"
194+
- src: "tool"
195+
dst: "/usr/lib/{{ .ProjectName }}/tool"
198196
- src: "builtin"
199197
dst: "/usr/lib/{{ .ProjectName }}/builtin"
200198
- src: "cl"
@@ -207,22 +205,14 @@ nfpms:
207205
dst: "/usr/lib/{{ .ProjectName }}/env"
208206
- src: "format"
209207
dst: "/usr/lib/{{ .ProjectName }}/format"
210-
- src: "gengo.go"
211-
dst: "/usr/lib/{{ .ProjectName }}/gengo.go"
212208
- src: "go.mod"
213209
dst: "/usr/lib/{{ .ProjectName }}/go.mod"
214210
- src: "go.sum"
215211
dst: "/usr/lib/{{ .ProjectName }}/go.sum"
216-
- src: "imp.go"
217-
dst: "/usr/lib/{{ .ProjectName }}/imp.go"
218-
- src: "load.go"
219-
dst: "/usr/lib/{{ .ProjectName }}/load.go"
220212
- src: "make.bash"
221213
dst: "/usr/lib/{{ .ProjectName }}/make.bash"
222214
- src: "make.bat"
223215
dst: "/usr/lib/{{ .ProjectName }}/make.bat"
224-
- src: "outline.go"
225-
dst: "/usr/lib/{{ .ProjectName }}/outline.go"
226216
- src: "parser"
227217
dst: "/usr/lib/{{ .ProjectName }}/parser"
228218
- src: "printer"
@@ -233,8 +223,6 @@ nfpms:
233223
dst: "/usr/lib/{{ .ProjectName }}/test"
234224
- src: "demo"
235225
dst: "/usr/lib/{{ .ProjectName }}/demo"
236-
- src: "tidy.go"
237-
dst: "/usr/lib/{{ .ProjectName }}/tidy.go"
238226
- src: "token"
239227
dst: "/usr/lib/{{ .ProjectName }}/token"
240228
- src: "x"
@@ -271,16 +259,14 @@ snapcrafts:
271259
destination: "Makefile"
272260
- source: "README.md"
273261
destination: "README.md"
274-
- source: "_gendeps.go"
275-
destination: "_gendeps.go"
276262
- source: "all.bash"
277263
destination: "all.bash"
278264
- source: "all.bat"
279265
destination: "all.bat"
280266
- source: "ast"
281267
destination: "ast"
282-
- source: "build_install_run.go"
283-
destination: "build_install_run.go"
268+
- source: "tool"
269+
destination: "tool"
284270
- source: "builtin"
285271
destination: "builtin"
286272
- source: "cl"
@@ -293,22 +279,14 @@ snapcrafts:
293279
destination: "env"
294280
- source: "format"
295281
destination: "format"
296-
- source: "gengo.go"
297-
destination: "gengo.go"
298282
- source: "go.mod"
299283
destination: "go.mod"
300284
- source: "go.sum"
301285
destination: "go.sum"
302-
- source: "imp.go"
303-
destination: "imp.go"
304-
- source: "load.go"
305-
destination: "load.go"
306286
- source: "make.bash"
307287
destination: "make.bash"
308288
- source: "make.bat"
309289
destination: "make.bat"
310-
- source: "outline.go"
311-
destination: "outline.go"
312290
- source: "parser"
313291
destination: "parser"
314292
- source: "printer"
@@ -319,8 +297,6 @@ snapcrafts:
319297
destination: "test"
320298
- source: "demo"
321299
destination: "demo"
322-
- source: "tidy.go"
323-
destination: "tidy.go"
324300
- source: "token"
325301
destination: "token"
326302
- source: "x"

cl/cltest/cltest.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,13 @@ import (
2626
"testing"
2727

2828
"github.com/goplus/gogen"
29-
"github.com/goplus/gop"
3029
"github.com/goplus/gop/cl"
3130
"github.com/goplus/gop/parser"
3231
"github.com/goplus/gop/parser/fsx"
3332
"github.com/goplus/gop/parser/fsx/memfs"
3433
"github.com/goplus/gop/scanner"
3534
"github.com/goplus/gop/token"
35+
"github.com/goplus/gop/tool"
3636
"github.com/goplus/mod/env"
3737
"github.com/goplus/mod/modfile"
3838
)
@@ -47,7 +47,7 @@ func init() {
4747
gogen.SetDebug(gogen.DbgFlagAll)
4848
cl.SetDebug(cl.DbgFlagAll | cl.FlagNoMarkAutogen)
4949
fset := token.NewFileSet()
50-
imp := gop.NewImporter(nil, Gop, fset)
50+
imp := tool.NewImporter(nil, Gop, fset)
5151
Conf = &cl.Config{
5252
Fset: fset,
5353
Importer: imp,

cl/typeparams_test.go

+16
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,19 @@
1+
/*
2+
* Copyright (c) 2022 The GoPlus Authors (goplus.org). All rights reserved.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
117
package cl_test
218

319
import (

cmd/chore/gopfmt/gopfmt.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ import (
3030

3131
goformat "go/format"
3232

33-
"github.com/goplus/gop"
3433
"github.com/goplus/gop/format"
34+
"github.com/goplus/gop/tool"
3535
)
3636

3737
var (
@@ -132,7 +132,7 @@ func (w *walker) walk(path string, d fs.DirEntry, err error) error {
132132
dir, _ := filepath.Split(path)
133133
fn, ok := w.dirMap[dir]
134134
if !ok {
135-
if mod, err := gop.LoadMod(path); err == nil {
135+
if mod, err := tool.LoadMod(path); err == nil {
136136
fn = func(ext string) (ok bool, class bool) {
137137
switch ext {
138138
case ".go", ".gop":

cmd/chore/goptestgo/goptestgo.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ import (
2828
"path/filepath"
2929
"time"
3030

31-
"github.com/goplus/gop"
31+
"github.com/goplus/gop/tool"
3232
"github.com/goplus/gop/x/gocmd"
3333
"github.com/goplus/gop/x/gopenv"
3434
)
@@ -43,7 +43,7 @@ func fileIsDirty(srcMod time.Time, destFile string) bool {
4343

4444
func runGoFile(dir, file, fname string) {
4545
gopEnv := gopenv.Get()
46-
conf := &gop.Config{Gop: gopEnv}
46+
conf := &tool.Config{Gop: gopEnv}
4747
confCmd := &gocmd.BuildConfig{Gop: gopEnv}
4848
fi, err := os.Stat(file)
4949
if err != nil {
@@ -53,7 +53,7 @@ func runGoFile(dir, file, fname string) {
5353
hash := sha1.Sum([]byte(absFile))
5454
outFile := dir + "g" + base64.RawURLEncoding.EncodeToString(hash[:]) + fname
5555
if fileIsDirty(fi.ModTime(), outFile) {
56-
err = gop.RunFiles(outFile, []string{file}, nil, conf, confCmd)
56+
err = tool.RunFiles(outFile, []string{file}, nil, conf, confCmd)
5757
if err != nil {
5858
os.Remove(outFile)
5959
switch e := err.(type) {

cmd/internal/build/build.go

+9-9
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@ import (
2525
"reflect"
2626

2727
"github.com/goplus/gogen"
28-
"github.com/goplus/gop"
2928
"github.com/goplus/gop/cl"
3029
"github.com/goplus/gop/cmd/internal/base"
30+
"github.com/goplus/gop/tool"
3131
"github.com/goplus/gop/x/gocmd"
3232
"github.com/goplus/gop/x/gopprojs"
3333
)
@@ -74,9 +74,9 @@ func runCmd(cmd *base.Command, args []string) {
7474
log.Panicln("too many arguments:", args)
7575
}
7676

77-
conf, err := gop.NewDefaultConf(".", gop.ConfFlagNoTestFiles, pass.Tags())
77+
conf, err := tool.NewDefaultConf(".", tool.ConfFlagNoTestFiles, pass.Tags())
7878
if err != nil {
79-
log.Panicln("gop.NewDefaultConf:", err)
79+
log.Panicln("tool.NewDefaultConf:", err)
8080
}
8181
defer conf.UpdateCache()
8282

@@ -92,23 +92,23 @@ func runCmd(cmd *base.Command, args []string) {
9292
build(proj, conf, confCmd)
9393
}
9494

95-
func build(proj gopprojs.Proj, conf *gop.Config, build *gocmd.BuildConfig) {
96-
const flags = gop.GenFlagPrompt
95+
func build(proj gopprojs.Proj, conf *tool.Config, build *gocmd.BuildConfig) {
96+
const flags = tool.GenFlagPrompt
9797
var obj string
9898
var err error
9999
switch v := proj.(type) {
100100
case *gopprojs.DirProj:
101101
obj = v.Dir
102-
err = gop.BuildDir(obj, conf, build, flags)
102+
err = tool.BuildDir(obj, conf, build, flags)
103103
case *gopprojs.PkgPathProj:
104104
obj = v.Path
105-
err = gop.BuildPkgPath("", v.Path, conf, build, flags)
105+
err = tool.BuildPkgPath("", v.Path, conf, build, flags)
106106
case *gopprojs.FilesProj:
107-
err = gop.BuildFiles(v.Files, conf, build)
107+
err = tool.BuildFiles(v.Files, conf, build)
108108
default:
109109
log.Panicln("`gop build` doesn't support", reflect.TypeOf(v))
110110
}
111-
if gop.NotFound(err) {
111+
if tool.NotFound(err) {
112112
fmt.Fprintf(os.Stderr, "gop build %v: not found\n", obj)
113113
} else if err != nil {
114114
fmt.Fprintln(os.Stderr, err)

cmd/internal/doc/doc.go

+6-6
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,10 @@ import (
2626
"strings"
2727

2828
"github.com/goplus/gogen"
29-
"github.com/goplus/gop"
3029
"github.com/goplus/gop/cl"
3130
"github.com/goplus/gop/cl/outline"
3231
"github.com/goplus/gop/cmd/internal/base"
32+
"github.com/goplus/gop/tool"
3333
"github.com/goplus/gop/x/gopenv"
3434
"github.com/goplus/gop/x/gopprojs"
3535
)
@@ -76,25 +76,25 @@ func runCmd(cmd *base.Command, args []string) {
7676
}
7777

7878
gopEnv := gopenv.Get()
79-
conf := &gop.Config{Gop: gopEnv}
79+
conf := &tool.Config{Gop: gopEnv}
8080
outlinePkg(proj, conf)
8181
}
8282

83-
func outlinePkg(proj gopprojs.Proj, conf *gop.Config) {
83+
func outlinePkg(proj gopprojs.Proj, conf *tool.Config) {
8484
var obj string
8585
var out outline.Package
8686
var err error
8787
switch v := proj.(type) {
8888
case *gopprojs.DirProj:
8989
obj = v.Dir
90-
out, err = gop.Outline(obj, conf)
90+
out, err = tool.Outline(obj, conf)
9191
case *gopprojs.PkgPathProj:
9292
obj = v.Path
93-
out, err = gop.OutlinePkgPath("", obj, conf, true)
93+
out, err = tool.OutlinePkgPath("", obj, conf, true)
9494
default:
9595
log.Panicln("`gop doc` doesn't support", reflect.TypeOf(v))
9696
}
97-
if gop.NotFound(err) {
97+
if tool.NotFound(err) {
9898
fmt.Fprintf(os.Stderr, "gop doc %v: not Go/Go+ files found\n", obj)
9999
} else if err != nil {
100100
fmt.Fprintln(os.Stderr, err)

cmd/internal/gengo/go.go

+9-9
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@ import (
2424
"reflect"
2525

2626
"github.com/goplus/gogen"
27-
"github.com/goplus/gop"
2827
"github.com/goplus/gop/cl"
2928
"github.com/goplus/gop/cmd/internal/base"
29+
"github.com/goplus/gop/tool"
3030
"github.com/goplus/gop/x/gopprojs"
3131
"github.com/qiniu/x/errors"
3232
)
@@ -72,30 +72,30 @@ func runCmd(cmd *base.Command, args []string) {
7272
cl.SetDisableRecover(true)
7373
}
7474

75-
conf, err := gop.NewDefaultConf(".", 0, *flagTags)
75+
conf, err := tool.NewDefaultConf(".", 0, *flagTags)
7676
if err != nil {
77-
log.Panicln("gop.NewDefaultConf:", err)
77+
log.Panicln("tool.NewDefaultConf:", err)
7878
}
7979
defer conf.UpdateCache()
8080

81-
flags := gop.GenFlagPrintError | gop.GenFlagPrompt
81+
flags := tool.GenFlagPrintError | tool.GenFlagPrompt
8282
if *flagCheckMode {
83-
flags |= gop.GenFlagCheckOnly
83+
flags |= tool.GenFlagCheckOnly
8484
if *flagIgnoreNotatedErr {
8585
conf.IgnoreNotatedError = true
8686
}
8787
}
8888
if *flagSingleMode {
89-
flags |= gop.GenFlagSingleFile
89+
flags |= tool.GenFlagSingleFile
9090
}
9191
for _, proj := range projs {
9292
switch v := proj.(type) {
9393
case *gopprojs.DirProj:
94-
_, _, err = gop.GenGoEx(v.Dir, conf, true, flags)
94+
_, _, err = tool.GenGoEx(v.Dir, conf, true, flags)
9595
case *gopprojs.PkgPathProj:
96-
_, _, err = gop.GenGoPkgPathEx("", v.Path, conf, true, flags)
96+
_, _, err = tool.GenGoPkgPathEx("", v.Path, conf, true, flags)
9797
case *gopprojs.FilesProj:
98-
_, err = gop.GenGoFiles("", v.Files, conf)
98+
_, err = tool.GenGoFiles("", v.Files, conf)
9999
default:
100100
log.Panicln("`gop go` doesn't support", reflect.TypeOf(v))
101101
}

cmd/internal/gopfmt/fmt.go

+2-3
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,9 @@ import (
2626
"path/filepath"
2727
"strings"
2828

29-
"github.com/goplus/gop"
30-
3129
"github.com/goplus/gop/cmd/internal/base"
3230
"github.com/goplus/gop/format"
31+
"github.com/goplus/gop/tool"
3332

3433
goformat "go/format"
3534
"go/parser"
@@ -147,7 +146,7 @@ func (w *walker) walk(path string, d fs.DirEntry, err error) error {
147146
dir, _ := filepath.Split(path)
148147
fn, ok := w.dirMap[dir]
149148
if !ok {
150-
if mod, err := gop.LoadMod(path); err == nil {
149+
if mod, err := tool.LoadMod(path); err == nil {
151150
fn = func(ext string) (ok bool, class bool) {
152151
switch ext {
153152
case ".go", ".gop":

cmd/internal/gopget/get.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ import (
2121
"log"
2222
"os"
2323

24-
"github.com/goplus/gop"
2524
"github.com/goplus/gop/cmd/internal/base"
25+
"github.com/goplus/gop/tool"
2626
"github.com/goplus/mod/modcache"
2727
"github.com/goplus/mod/modfetch"
2828
"github.com/goplus/mod/modload"
@@ -62,7 +62,7 @@ func runCmd(cmd *base.Command, args []string) {
6262
func get(pkgPath string) {
6363
modBase := ""
6464
mod, err := modload.Load(".")
65-
noMod := gop.NotFound(err)
65+
noMod := tool.NotFound(err)
6666
if !noMod {
6767
check(err)
6868
modBase = mod.Path()

0 commit comments

Comments
 (0)