Skip to content
This repository was archived by the owner on Jun 25, 2022. It is now read-only.

Commit 5d4036d

Browse files
committed
deprecated internal/envy.go now go modules mode only.
1 parent bcffcc4 commit 5d4036d

File tree

4 files changed

+26
-82
lines changed

4 files changed

+26
-82
lines changed

go.mod

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module github.com/gobuffalo/packr/v2
22

3-
go 1.13
3+
go 1.16
44

55
require (
66
github.com/gobuffalo/logger v1.0.6

go.sum

-2
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,6 @@ golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
298298
golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
299299
golang.org/x/mod v0.4.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
300300
golang.org/x/mod v0.4.1/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
301-
golang.org/x/mod v0.4.2 h1:Gz96sIWK3OalVv/I/qNygP42zyoKp3xptRVCWRFEBvo=
302301
golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
303302
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
304303
golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
@@ -477,7 +476,6 @@ golang.org/x/tools v0.1.7/go.mod h1:LGqMHiF4EqQNHR1JncWGqT5BVaXmza+X+BDGol+dOxo=
477476
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
478477
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
479478
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
480-
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE=
481479
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
482480
google.golang.org/api v0.4.0/go.mod h1:8k5glujaEP+g9n7WNsDg8QP6cUVNI86fCNMcbazEtwE=
483481
google.golang.org/api v0.7.0/go.mod h1:WtwebWUNSVBH/HAw79HIFXZNqEvBhG+Ra+ax0hx3E3M=

internal/envy.go

-37
This file was deleted.

jam/store/disk.go

+25-42
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import (
55
"compress/gzip"
66
"crypto/md5"
77
"fmt"
8-
"go/build"
98
"html/template"
109
"io"
1110
"io/ioutil"
@@ -17,7 +16,6 @@ import (
1716
"strings"
1817
"sync"
1918

20-
"github.com/gobuffalo/packr/v2/internal"
2119
"github.com/karrick/godirwalk"
2220

2321
"github.com/gobuffalo/packr/v2/file/resolver/encoding/hex"
@@ -255,49 +253,34 @@ func (d *Disk) Close() error {
255253
}
256254

257255
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")
294271
}
295-
ip = strings.TrimPrefix(ip, string(filepath.Separator))
296-
ip = strings.TrimPrefix(ip, "src")
297-
ip = strings.TrimPrefix(ip, string(filepath.Separator))
272+
}
298273

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")
300281
}
282+
ip = filepath.Join(ip, strings.TrimPrefix(filepath.Dir(d.DBPath), filepath.Dir(mp)))
283+
ip = strings.Replace(ip, "\\", "/", -1)
301284
ip = path.Join(ip, d.DBPackage)
302285

303286
for _, n := range opts.Boxes {

0 commit comments

Comments
 (0)