This repository has been archived by the owner on Nov 23, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
22 changed files
with
3,990 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
package scan | ||
|
||
import ( | ||
"github.com/BurntSushi/toml" | ||
log "github.com/sirupsen/logrus" | ||
) | ||
|
||
type GoPkgLockDeps struct { | ||
Name string | ||
Version string | ||
Gofiles []string | ||
} | ||
|
||
type goPkg struct { | ||
Name string `toml:"name"` | ||
Packages []string `toml:"packages"` | ||
Revision string `toml:"revision"` | ||
Version string `toml:"version"` | ||
} | ||
|
||
type goPkgDeps struct { | ||
Deps []goPkg `toml:"projects"` | ||
} | ||
|
||
func GetGoPkgDeps(path string) ([]GoPkgLockDeps, error) { | ||
log.Debugf("GetGoPkgDeps %s", path) | ||
|
||
var deps goPkgDeps | ||
var gathered []GoPkgLockDeps | ||
|
||
_, err := toml.DecodeFile(path, &deps) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
for _, d := range deps.Deps { | ||
ver := d.Version | ||
if ver == "" { | ||
ver = d.Revision | ||
} | ||
|
||
var files []string | ||
if len(d.Packages) > 1 { | ||
files = append(files, d.Packages...) | ||
} | ||
|
||
gathered = append(gathered, | ||
GoPkgLockDeps{ | ||
Name: d.Name, | ||
Version: ver, | ||
Gofiles: files, | ||
}, | ||
) | ||
} | ||
|
||
return gathered, nil | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.