aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/github.com/99designs/gqlgen/internal
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/github.com/99designs/gqlgen/internal')
-rw-r--r--vendor/github.com/99designs/gqlgen/internal/code/imports.go9
-rw-r--r--vendor/github.com/99designs/gqlgen/internal/imports/prune.go9
2 files changed, 8 insertions, 10 deletions
diff --git a/vendor/github.com/99designs/gqlgen/internal/code/imports.go b/vendor/github.com/99designs/gqlgen/internal/code/imports.go
index 75c30fe1..ad62f7c5 100644
--- a/vendor/github.com/99designs/gqlgen/internal/code/imports.go
+++ b/vendor/github.com/99designs/gqlgen/internal/code/imports.go
@@ -62,22 +62,23 @@ func ImportPathForDir(dir string) (res string) {
modDir := dir
assumedPart := ""
for {
- f, err := ioutil.ReadFile(filepath.Join(modDir, "/", "go.mod"))
+ f, err := ioutil.ReadFile(filepath.Join(modDir, "go.mod"))
if err == nil {
// found it, stop searching
return string(modregex.FindSubmatch(f)[1]) + assumedPart
}
assumedPart = "/" + filepath.Base(modDir) + assumedPart
- modDir, err = filepath.Abs(filepath.Join(modDir, ".."))
+ parentDir, err := filepath.Abs(filepath.Join(modDir, ".."))
if err != nil {
panic(err)
}
- // Walked all the way to the root and didnt find anything :'(
- if modDir == "/" {
+ if parentDir == modDir {
+ // Walked all the way to the root and didnt find anything :'(
break
}
+ modDir = parentDir
}
for _, gopath := range gopaths {
diff --git a/vendor/github.com/99designs/gqlgen/internal/imports/prune.go b/vendor/github.com/99designs/gqlgen/internal/imports/prune.go
index d678870e..27ac94ac 100644
--- a/vendor/github.com/99designs/gqlgen/internal/imports/prune.go
+++ b/vendor/github.com/99designs/gqlgen/internal/imports/prune.go
@@ -32,10 +32,7 @@ func Prune(filename string, src []byte) ([]byte, error) {
return nil, err
}
- unused, err := getUnusedImports(file, filename)
- if err != nil {
- return nil, err
- }
+ unused := getUnusedImports(file)
for ipath, name := range unused {
astutil.DeleteNamedImport(fset, file, name, ipath)
}
@@ -49,7 +46,7 @@ func Prune(filename string, src []byte) ([]byte, error) {
return imports.Process(filename, buf.Bytes(), &imports.Options{FormatOnly: true, Comments: true, TabIndent: true, TabWidth: 8})
}
-func getUnusedImports(file ast.Node, filename string) (map[string]string, error) {
+func getUnusedImports(file ast.Node) map[string]string {
imported := map[string]*ast.ImportSpec{}
used := map[string]bool{}
@@ -99,5 +96,5 @@ func getUnusedImports(file ast.Node, filename string) (map[string]string, error)
}
}
- return unusedImport, nil
+ return unusedImport
}