5
5
"compress/gzip"
6
6
"crypto/md5"
7
7
"fmt"
8
- "go/build"
9
8
"html/template"
10
9
"io"
11
10
"io/ioutil"
@@ -17,7 +16,6 @@ import (
17
16
"strings"
18
17
"sync"
19
18
20
- "github.com/gobuffalo/packr/v2/internal"
21
19
"github.com/karrick/godirwalk"
22
20
23
21
"github.com/gobuffalo/packr/v2/file/resolver/encoding/hex"
@@ -255,49 +253,34 @@ func (d *Disk) Close() error {
255
253
}
256
254
257
255
var ip string
258
- if internal .Mods () {
259
- // Starting in 1.12, we can rely on Go's method for
260
- // resolving where go.mod resides. Prior versions will
261
- // simply return an empty string.
262
- cmd := exec .Command ("go" , "env" , "GOMOD" )
263
- out , err := cmd .Output ()
264
- if err != nil {
265
- return fmt .Errorf ("go.mod cannot be read or does not exist while go module is enabled" )
266
- }
267
- mp := strings .TrimSpace (string (out ))
268
- if mp == "" {
269
- // We are on a prior version of Go; try and do
270
- // the resolution ourselves.
271
- mp = filepath .Join (filepath .Dir (d .DBPath ), "go.mod" )
272
- if _ , err := os .Stat (mp ); err != nil {
273
- mp = filepath .Join (d .DBPath , "go.mod" )
274
- }
275
- }
276
-
277
- moddata , err := ioutil .ReadFile (mp )
278
- if err != nil {
279
- return fmt .Errorf ("go.mod cannot be read or does not exist while go module is enabled" )
280
- }
281
- ip = modfile .ModulePath (moddata )
282
- if ip == "" {
283
- return fmt .Errorf ("go.mod is malformed" )
284
- }
285
- ip = filepath .Join (ip , strings .TrimPrefix (filepath .Dir (d .DBPath ), filepath .Dir (mp )))
286
- ip = strings .Replace (ip , "\\ " , "/" , - 1 )
287
- } else {
288
- ip = filepath .Dir (d .DBPath )
289
- srcs := internal .GoPaths ()
290
- srcs = append (srcs , build .Default .SrcDirs ()... )
291
- for _ , x := range srcs {
292
- ip = strings .TrimPrefix (ip , "/private" )
293
- ip = strings .TrimPrefix (ip , x )
256
+ // Starting in 1.12, we can rely on Go's method for
257
+ // resolving where go.mod resides. Prior versions will
258
+ // simply return an empty string.
259
+ cmd := exec .Command ("go" , "env" , "GOMOD" )
260
+ out , err := cmd .Output ()
261
+ if err != nil {
262
+ return fmt .Errorf ("go.mod cannot be read or does not exist while go module is enabled" )
263
+ }
264
+ mp := strings .TrimSpace (string (out ))
265
+ if mp == "" {
266
+ // We are on a prior version of Go; try and do
267
+ // the resolution ourselves.
268
+ mp = filepath .Join (filepath .Dir (d .DBPath ), "go.mod" )
269
+ if _ , err := os .Stat (mp ); err != nil {
270
+ mp = filepath .Join (d .DBPath , "go.mod" )
294
271
}
295
- ip = strings .TrimPrefix (ip , string (filepath .Separator ))
296
- ip = strings .TrimPrefix (ip , "src" )
297
- ip = strings .TrimPrefix (ip , string (filepath .Separator ))
272
+ }
298
273
299
- ip = strings .Replace (ip , "\\ " , "/" , - 1 )
274
+ moddata , err := ioutil .ReadFile (mp )
275
+ if err != nil {
276
+ return fmt .Errorf ("go.mod cannot be read or does not exist while go module is enabled" )
277
+ }
278
+ ip = modfile .ModulePath (moddata )
279
+ if ip == "" {
280
+ return fmt .Errorf ("go.mod is malformed" )
300
281
}
282
+ ip = filepath .Join (ip , strings .TrimPrefix (filepath .Dir (d .DBPath ), filepath .Dir (mp )))
283
+ ip = strings .Replace (ip , "\\ " , "/" , - 1 )
301
284
ip = path .Join (ip , d .DBPackage )
302
285
303
286
for _ , n := range opts .Boxes {
0 commit comments