Skip to content

Commit 266314a

Browse files
committed
fix: update some remaining mode file reference go.mod -> gno.mod
Signed-off-by: gfanton <[email protected]>
1 parent 8d9c36d commit 266314a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+199
-199
lines changed

Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
.PHONY: install
22
install:
3-
go install .
3+
go install -v .

doc/generate/generate.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -482,7 +482,7 @@ func loadLenses(settingsPkg *packages.Package, defaults map[settings.CodeLensSou
482482
return nil
483483
}
484484
addAll(golang.CodeLensSources(), "Go")
485-
addAll(mod.CodeLensSources(), "go.mod")
485+
addAll(mod.CodeLensSources(), "gno.mod")
486486
return lenses, nil
487487
}
488488

internal/cache/load.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -708,7 +708,7 @@ func isWorkspacePackageLocked(ctx context.Context, s *Snapshot, meta *metadata.G
708708
}
709709
dir := pkg.CompiledGoFiles[0].Dir()
710710
var err error
711-
modURI, err = findRootPattern(ctx, dir, "go.mod", lockedSnapshot{s})
711+
modURI, err = findRootPattern(ctx, dir, "gno.mod", lockedSnapshot{s})
712712
if err != nil || modURI == "" {
713713
// err != nil implies context cancellation, in which case the result of
714714
// this query does not matter.

internal/cache/mod_tidy.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ func modTidyImpl(ctx context.Context, snapshot *Snapshot, pm *ParsedModule) (*Ti
110110

111111
inv, cleanupInvocation, err := snapshot.GoCommandInvocation(false, &gocommand.Invocation{
112112
Verb: "mod",
113-
Args: []string{"tidy", "-modfile=" + filepath.Join(tempDir, "go.mod")},
113+
Args: []string{"tidy", "-modfile=" + filepath.Join(tempDir, "gno.mod")},
114114
Env: []string{"GOWORK=off"},
115115
WorkingDir: pm.URI.Dir().Path(),
116116
})
@@ -124,7 +124,7 @@ func modTidyImpl(ctx context.Context, snapshot *Snapshot, pm *ParsedModule) (*Ti
124124

125125
// Go directly to disk to get the temporary mod file,
126126
// since it is always on disk.
127-
tempMod := filepath.Join(tempDir, "go.mod")
127+
tempMod := filepath.Join(tempDir, "gno.mod")
128128
tempContents, err := os.ReadFile(tempMod)
129129
if err != nil {
130130
return nil, err

internal/cache/session.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -585,7 +585,7 @@ func RelevantViews[V viewDefiner](ctx context.Context, fs file.Source, uri proto
585585
return nil, nil // avoid the call to findRootPattern
586586
}
587587
dir := uri.Dir()
588-
modURI, err := findRootPattern(ctx, dir, "go.mod", fs)
588+
modURI, err := findRootPattern(ctx, dir, "gno.mod", fs)
589589
if err != nil {
590590
return nil, err
591591
}

internal/cache/session_test.go

+6-6
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ func TestZeroConfigAlgorithm(t *testing.T) {
6868
{
6969
"basic go.mod workspace",
7070
map[string]string{
71-
"go.mod": "module golang.org/a\ngo 1.18\n",
71+
"gno.mod": "module golang.org/a\ngo 1.18\n",
7272
},
7373
[]folderSummary{{dir: "."}},
7474
nil,
@@ -237,7 +237,7 @@ func TestZeroConfigAlgorithm(t *testing.T) {
237237
{
238238
"go.mod with nested replace",
239239
map[string]string{
240-
"go.mod": "module golang.org/a\n require golang.org/b v1.2.3\nreplace example.com/b => ./b",
240+
"gno.mod": "module golang.org/a\n require golang.org/b v1.2.3\nreplace example.com/b => ./b",
241241
"a.go": "package a",
242242
"b/go.mod": "module golang.org/b\ngo 1.18\n",
243243
"b/b.go": "package b",
@@ -249,7 +249,7 @@ func TestZeroConfigAlgorithm(t *testing.T) {
249249
{
250250
"go.mod with parent replace, parent folder",
251251
map[string]string{
252-
"go.mod": "module golang.org/a",
252+
"gno.mod": "module golang.org/a",
253253
"a.go": "package a",
254254
"b/go.mod": "module golang.org/b\ngo 1.18\nrequire golang.org/a v1.2.3\nreplace golang.org/a => ../",
255255
"b/b.go": "package b",
@@ -261,7 +261,7 @@ func TestZeroConfigAlgorithm(t *testing.T) {
261261
{
262262
"go.mod with multiple replace",
263263
map[string]string{
264-
"go.mod": `
264+
"gno.mod": `
265265
module golang.org/root
266266
267267
require (
@@ -291,7 +291,7 @@ replace (
291291
{
292292
"go.mod with replace outside the workspace",
293293
map[string]string{
294-
"go.mod": "module golang.org/a\ngo 1.18",
294+
"gno.mod": "module golang.org/a\ngo 1.18",
295295
"a.go": "package a",
296296
"b/go.mod": "module golang.org/b\ngo 1.18\nrequire golang.org/a v1.2.3\nreplace golang.org/a => ../",
297297
"b/b.go": "package b",
@@ -303,7 +303,7 @@ replace (
303303
{
304304
"go.mod with replace directive; workspace replace off",
305305
map[string]string{
306-
"go.mod": "module golang.org/a\n require golang.org/b v1.2.3\nreplace example.com/b => ./b",
306+
"gno.mod": "module golang.org/a\n require golang.org/b v1.2.3\nreplace example.com/b => ./b",
307307
"a.go": "package a",
308308
"b/go.mod": "module golang.org/b\ngo 1.18\n",
309309
"b/b.go": "package b",

internal/cache/snapshot.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -427,7 +427,7 @@ func (s *Snapshot) RunGoModUpdateCommands(ctx context.Context, modURI protocol.D
427427
inv, cleanupInvocation, err := s.GoCommandInvocation(true, &gocommand.Invocation{
428428
WorkingDir: modURI.Dir().Path(),
429429
ModFlag: "mod",
430-
ModFile: filepath.Join(tempDir, "go.mod"),
430+
ModFile: filepath.Join(tempDir, "gno.mod"),
431431
Env: []string{"GOWORK=off"},
432432
})
433433
if err != nil {
@@ -443,7 +443,7 @@ func (s *Snapshot) RunGoModUpdateCommands(ctx context.Context, modURI protocol.D
443443
return nil, nil, err
444444
}
445445
var modBytes, sumBytes []byte
446-
modBytes, err = os.ReadFile(filepath.Join(tempDir, "go.mod"))
446+
modBytes, err = os.ReadFile(filepath.Join(tempDir, "gno.mod"))
447447
if err != nil && !os.IsNotExist(err) {
448448
return nil, nil, err
449449
}
@@ -480,7 +480,7 @@ func TempModDir(ctx context.Context, fs file.Source, modURI protocol.DocumentURI
480480
return "", nil, err // context cancelled
481481
}
482482
if data, err := modFH.Content(); err == nil {
483-
if err := os.WriteFile(filepath.Join(dir, "go.mod"), data, 0666); err != nil {
483+
if err := os.WriteFile(filepath.Join(dir, "gno.mod"), data, 0666); err != nil {
484484
return "", nil, err
485485
}
486486
}
@@ -1770,7 +1770,7 @@ func (s *Snapshot) clone(ctx, bgCtx context.Context, changed StateChange, done f
17701770
reinit = true
17711771
}
17721772
if base == "go.sum" {
1773-
modURI := protocol.URIFromPath(filepath.Join(dir, "go.mod"))
1773+
modURI := protocol.URIFromPath(filepath.Join(dir, "gno.mod"))
17741774
if _, active := result.view.workspaceModFiles[modURI]; active {
17751775
reinit = true
17761776
}

internal/cache/view.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -864,7 +864,7 @@ func defineView(ctx context.Context, fs file.Source, folder *Folder, forFile fil
864864

865865
// When deriving the best view for a given file, we only want to search
866866
// up the directory hierarchy for modfiles.
867-
def.gomod, err = findRootPattern(ctx, dirURI, "go.mod", fs)
867+
def.gomod, err = findRootPattern(ctx, dirURI, "gno.mod", fs)
868868
if err != nil {
869869
return nil, err
870870
}

internal/cache/workspace.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -54,15 +54,15 @@ func localModFiles(relativeTo string, goWorkOrModPaths []string) map[protocol.Do
5454
if !filepath.IsAbs(modDir) {
5555
modDir = filepath.Join(relativeTo, modDir)
5656
}
57-
modURI := protocol.URIFromPath(filepath.Join(modDir, "go.mod"))
57+
modURI := protocol.URIFromPath(filepath.Join(modDir, "gno.mod"))
5858
modFiles[modURI] = unit{}
5959
}
6060
return modFiles
6161
}
6262

6363
// isGoMod reports if uri is a go.mod file.
6464
func isGoMod(uri protocol.DocumentURI) bool {
65-
return filepath.Base(uri.Path()) == "go.mod"
65+
return filepath.Base(uri.Path()) == "gno.mod"
6666
}
6767

6868
// goModModules returns the URIs of "workspace" go.mod files defined by a

internal/cmd/capabilities_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ func TestCapabilities(t *testing.T) {
3535
if err := os.WriteFile(tmpFile, []byte(""), 0775); err != nil {
3636
t.Fatal(err)
3737
}
38-
if err := os.WriteFile(filepath.Join(tmpDir, "go.mod"), []byte("module fake\n\ngo 1.12\n"), 0775); err != nil {
38+
if err := os.WriteFile(filepath.Join(tmpDir, "gno.mod"), []byte("module fake\n\ngo 1.12\n"), 0775); err != nil {
3939
t.Fatal(err)
4040
}
4141
defer os.RemoveAll(tmpDir)

internal/doc/api.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ type EnumValue struct {
5454
}
5555

5656
type Lens struct {
57-
FileType string // e.g. "Go", "go.mod"
57+
FileType string // e.g. "Go", "gno.mod"
5858
Lens string
5959
Title string
6060
Doc string

internal/doc/api.json

+4-4
Original file line numberDiff line numberDiff line change
@@ -969,28 +969,28 @@
969969
"Default": false
970970
},
971971
{
972-
"FileType": "go.mod",
972+
"FileType": "gno.mod",
973973
"Lens": "run_govulncheck",
974974
"Title": "Run govulncheck",
975975
"Doc": "\nThis codelens source annotates the `module` directive in a\ngo.mod file with a command to run Govulncheck.\n\n[Govulncheck](https://go.dev/blog/vuln) is a static\nanalysis tool that computes the set of functions reachable\nwithin your application, including dependencies;\nqueries a database of known security vulnerabilities; and\nreports any potential problems it finds.\n",
976976
"Default": false
977977
},
978978
{
979-
"FileType": "go.mod",
979+
"FileType": "gno.mod",
980980
"Lens": "tidy",
981981
"Title": "Tidy go.mod file",
982982
"Doc": "\nThis codelens source annotates the `module` directive in a\ngo.mod file with a command to run [`go mod\ntidy`](https://go.dev/ref/mod#go-mod-tidy), which ensures\nthat the go.mod file matches the source code in the module.\n",
983983
"Default": true
984984
},
985985
{
986-
"FileType": "go.mod",
986+
"FileType": "gno.mod",
987987
"Lens": "upgrade_dependency",
988988
"Title": "Update dependencies",
989989
"Doc": "\nThis codelens source annotates the `module` directive in a\ngo.mod file with commands to:\n\n- check for available upgrades,\n- upgrade direct dependencies, and\n- upgrade all dependencies transitively.\n",
990990
"Default": true
991991
},
992992
{
993-
"FileType": "go.mod",
993+
"FileType": "gno.mod",
994994
"Lens": "vendor",
995995
"Title": "Update vendor directory",
996996
"Doc": "\nThis codelens source annotates the `module` directive in a\ngo.mod file with a command to run [`go mod\nvendor`](https://go.dev/ref/mod#go-mod-vendor), which\ncreates or updates the directory named `vendor` in the\nmodule root so that it contains an up-to-date copy of all\nnecessary package dependencies.\n",

internal/imports/mod.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -509,14 +509,14 @@ func (r *ModuleResolver) modInfo(dir string) (modDir, modName string) {
509509
if matches := modCacheRegexp.FindStringSubmatch(dir); len(matches) == 3 {
510510
index := strings.Index(dir, matches[1]+"@"+matches[2])
511511
modDir := filepath.Join(dir[:index], matches[1]+"@"+matches[2])
512-
return modDir, readModName(filepath.Join(modDir, "go.mod"))
512+
return modDir, readModName(filepath.Join(modDir, "gno.mod"))
513513
}
514514
}
515515
for {
516516
if info, ok := r.cacheLoad(dir); ok {
517517
return info.moduleDir, info.moduleName
518518
}
519-
f := filepath.Join(dir, "go.mod")
519+
f := filepath.Join(dir, "gno.mod")
520520
info, err := os.Stat(f)
521521
if err == nil && !info.IsDir() {
522522
return dir, readModName(f)

internal/imports/mod_cache.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,7 @@ func ScanModuleCache(dir string, cache *DirInfoCache, logf func(string, ...any))
297297
importPath := path.Join(modPath, filepath.ToSlash(matches[3]))
298298
index := strings.Index(dir, matches[1]+"@"+matches[2])
299299
modDir := filepath.Join(dir[:index], matches[1]+"@"+matches[2])
300-
modName := readModName(filepath.Join(modDir, "go.mod"))
300+
modName := readModName(filepath.Join(modDir, "gno.mod"))
301301
return directoryPackageInfo{
302302
status: directoryScanned,
303303
dir: dir,

internal/imports/mod_test.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -194,18 +194,18 @@ import _ "rsc.io/quote"
194194
}
195195

196196
// Update the go.mod file of example.com so that it changes its module path (not allowed).
197-
if err := os.Chmod(filepath.Join(found.dir, "go.mod"), 0644); err != nil {
197+
if err := os.Chmod(filepath.Join(found.dir, "gno.mod"), 0644); err != nil {
198198
t.Fatal(err)
199199
}
200-
if err := os.WriteFile(filepath.Join(found.dir, "go.mod"), []byte("module bad.com\n"), 0644); err != nil {
200+
if err := os.WriteFile(filepath.Join(found.dir, "gno.mod"), []byte("module bad.com\n"), 0644); err != nil {
201201
t.Fatal(err)
202202
}
203203

204204
// Test that with its cache of module packages it still finds the package.
205205
mt.assertScanFinds("rsc.io/quote", "quote")
206206

207207
// Rewrite the main package so that rsc.io/quote is not in scope.
208-
if err := os.WriteFile(filepath.Join(mt.env.WorkingDir, "go.mod"), []byte("module x\n"), 0644); err != nil {
208+
if err := os.WriteFile(filepath.Join(mt.env.WorkingDir, "gno.mod"), []byte("module x\n"), 0644); err != nil {
209209
t.Fatal(err)
210210
}
211211
if err := os.WriteFile(filepath.Join(mt.env.WorkingDir, "x.go"), []byte("package x\n"), 0644); err != nil {
@@ -1033,7 +1033,7 @@ func setup(t *testing.T, extraEnv map[string]string, main, wd string) *modTest {
10331033
env.Logf = log.Printf
10341034
}
10351035
// go mod download gets mad if we don't have a go.mod, so make sure we do.
1036-
_, err = os.Stat(filepath.Join(mainDir, "go.mod"))
1036+
_, err = os.Stat(filepath.Join(mainDir, "gno.mod"))
10371037
if err != nil && !os.IsNotExist(err) {
10381038
t.Fatalf("checking if go.mod exists: %v", err)
10391039
}

internal/packages/overlay_test.go

+5-5
Original file line numberDiff line numberDiff line change
@@ -564,7 +564,7 @@ func TestOverlayModFileChanges(t *testing.T) {
564564
if err != nil {
565565
t.Fatal(err)
566566
}
567-
if err := os.WriteFile(filepath.Join(mod1, "go.mod"), []byte(`module mod1
567+
if err := os.WriteFile(filepath.Join(mod1, "gno.mod"), []byte(`module mod1
568568
569569
require (
570570
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7
@@ -583,7 +583,7 @@ func TestOverlayModFileChanges(t *testing.T) {
583583
584584
go 1.11
585585
`
586-
if err := os.WriteFile(filepath.Join(mod2, "go.mod"), []byte(want), 0775); err != nil {
586+
if err := os.WriteFile(filepath.Join(mod2, "gno.mod"), []byte(want), 0775); err != nil {
587587
t.Fatal(err)
588588
}
589589

@@ -609,7 +609,7 @@ func main() {}
609609
}
610610

611611
// Check that mod2/go.mod has not been modified.
612-
got, err := os.ReadFile(filepath.Join(mod2, "go.mod"))
612+
got, err := os.ReadFile(filepath.Join(mod2, "gno.mod"))
613613
if err != nil {
614614
t.Fatal(err)
615615
}
@@ -1054,7 +1054,7 @@ func TestOverlaysInReplace(t *testing.T) {
10541054
if err := os.Mkdir(dirB, 0775); err != nil {
10551055
t.Fatal(err)
10561056
}
1057-
if err := os.WriteFile(filepath.Join(dirB, "go.mod"), []byte(fmt.Sprintf("module %s.com", dirB)), 0775); err != nil {
1057+
if err := os.WriteFile(filepath.Join(dirB, "gno.mod"), []byte(fmt.Sprintf("module %s.com", dirB)), 0775); err != nil {
10581058
t.Fatal(err)
10591059
}
10601060
if err := os.MkdirAll(filepath.Join(dirB, "inner"), 0775); err != nil {
@@ -1077,7 +1077,7 @@ replace (
10771077
b.com => %s
10781078
)
10791079
`, dirB)
1080-
if err := os.WriteFile(filepath.Join(tmpWorkspace, "go.mod"), []byte(goModContent), 0775); err != nil {
1080+
if err := os.WriteFile(filepath.Join(tmpWorkspace, "gno.mod"), []byte(goModContent), 0775); err != nil {
10811081
t.Fatal(err)
10821082
}
10831083

internal/packages/packages_test.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -2713,8 +2713,8 @@ func testModule(t *testing.T, exporter packagestest.Exporter) {
27132713
if a.Module.Path != "golang.org/fake" {
27142714
t.Fatalf("package.Modile.Path: want \"golang.org/fake\", got %q", a.Module.Path)
27152715
}
2716-
if a.Module.GoMod != filepath.Join(rootDir, "go.mod") {
2717-
t.Fatalf("package.Module.GoMod: want %q, got %q", filepath.Join(rootDir, "go.mod"), a.Module.GoMod)
2716+
if a.Module.GoMod != filepath.Join(rootDir, "gno.mod") {
2717+
t.Fatalf("package.Module.GoMod: want %q, got %q", filepath.Join(rootDir, "gno.mod"), a.Module.GoMod)
27182718
}
27192719
default:
27202720
t.Fatalf("Expected exporter to be GOPATH or Modules, got %v", exported.Exporter.Name())
@@ -3002,7 +3002,7 @@ func copyAll(srcPath, dstPath string) error {
30023002
if err != nil {
30033003
return err
30043004
}
3005-
dstFilePath := strings.Replace(filepath.Join(dstPath, rel), "definitelynot_go.mod", "go.mod", -1)
3005+
dstFilePath := strings.Replace(filepath.Join(dstPath, rel), "definitelynot_go.mod", "gno.mod", -1)
30063006
if err := os.MkdirAll(filepath.Dir(dstFilePath), 0755); err != nil {
30073007
return err
30083008
}
@@ -3080,7 +3080,7 @@ func TestLoadOverlayGoMod(t *testing.T) {
30803080
cfg := &packages.Config{
30813081
Mode: packages.LoadSyntax,
30823082
Overlay: map[string][]byte{
3083-
filepath.Join(cwd, "go.mod"): []byte("module example.com\ngo 1.0"),
3083+
filepath.Join(cwd, "gno.mod"): []byte("module example.com\ngo 1.0"),
30843084
},
30853085
Env: append(os.Environ(), "GOFLAGS=-mod=vendor", "GOWORK=off"),
30863086
}

internal/packages/packagestest/expect.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ func (e *Exported) getNotes() error {
181181
}
182182
// Check go.mod markers regardless of mode, we need to do this so that our marker count
183183
// matches the counts in the summary.txt.golden file for the test directory.
184-
if gomod, found := e.written[e.primary]["go.mod"]; found {
184+
if gomod, found := e.written[e.primary]["gno.mod"]; found {
185185
// If we are in Modules mode, then we need to check the contents of the go.mod.temp.
186186
if e.Exporter == Modules {
187187
gomod += ".temp"

internal/packages/packagestest/export.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -596,7 +596,7 @@ func MustCopyFileTree(root string) map[string]interface{} {
596596
if info.IsDir() {
597597
// skip nested modules.
598598
if path != root {
599-
if fi, err := os.Stat(filepath.Join(path, "go.mod")); err == nil && !fi.IsDir() {
599+
if fi, err := os.Stat(filepath.Join(path, "gno.mod")); err == nil && !fi.IsDir() {
600600
return filepath.SkipDir
601601
}
602602
}

internal/packages/packagestest/export_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ func TestMustCopyFiles(t *testing.T) {
187187
// Create the following test directory structure in a temporary directory.
188188
src := map[string]string{
189189
// copies all files under the specified directory.
190-
"go.mod": "module example.com",
190+
"gno.mod": "module example.com",
191191
"m.go": "package m",
192192
"a/a.go": "package a",
193193
// contents from a nested module shouldn't be copied.
@@ -217,7 +217,7 @@ func TestMustCopyFiles(t *testing.T) {
217217
for fragment := range copied {
218218
got = append(got, filepath.ToSlash(fragment))
219219
}
220-
want := []string{"go.mod", "m.go", "a/a.go"}
220+
want := []string{"gno.mod", "m.go", "a/a.go"}
221221

222222
sort.Strings(got)
223223
sort.Strings(want)

0 commit comments

Comments
 (0)