@@ -121,11 +121,10 @@ func TestTags(t *testing.T) {
121
121
t .Fatal (err )
122
122
}
123
123
}
124
- // Run stringer in the directory that contains the package files.
125
- // We cannot run stringer in the current directory for the following reasons:
126
- // - Versions of Go earlier than Go 1.11, do not support absolute directories as a pattern.
127
- // - When the current directory is inside a go module, the path will not be considered
128
- // a valid path to a package.
124
+ // Run stringer in the directory that contains the module that contains the package files.
125
+ if err := os .WriteFile (filepath .Join (dir , "go.mod" ), []byte ("module test\n " ), 0o600 ); err != nil {
126
+ t .Fatal (err )
127
+ }
129
128
err := runInDir (t , dir , stringer , "-type" , "Const" , "." )
130
129
if err != nil {
131
130
t .Fatal (err )
@@ -167,7 +166,10 @@ func TestConstValueChange(t *testing.T) {
167
166
t .Fatal (err )
168
167
}
169
168
stringSource := filepath .Join (dir , "day_string.go" )
170
- // Run stringer in the directory that contains the package files.
169
+ // Run stringer in the directory that contains the module that contains the package files.
170
+ if err := os .WriteFile (filepath .Join (dir , "go.mod" ), []byte ("module test\n " ), 0o600 ); err != nil {
171
+ t .Fatal (err )
172
+ }
171
173
err = runInDir (t , dir , stringer , "-type" , "Day" , "-output" , stringSource )
172
174
if err != nil {
173
175
t .Fatal (err )
@@ -388,7 +390,6 @@ func runInDir(t testing.TB, dir, name string, arg ...string) error {
388
390
t .Helper ()
389
391
cmd := testenv .Command (t , name , arg ... )
390
392
cmd .Dir = dir
391
- cmd .Env = append (os .Environ (), "GO111MODULE=auto" )
392
393
out , err := cmd .CombinedOutput ()
393
394
if len (out ) > 0 {
394
395
t .Logf ("%s" , out )
0 commit comments