Sha256: 15da84c623d81fe37e06869f4c38b2fbae23ed0ea4ed8581dd20bf44bab0c4d4
Contents?: true
Size: 872 Bytes
Versions: 696
Compression:
Stored size: 872 Bytes
Contents
package updater import ( "io/ioutil" "github.com/dependabot/gomodules-extracted/cmd/go/_internal_/modfile" ) type Dependency struct { Name string `json:"name"` Version string `json:"version"` Indirect bool `json:"indirect"` } type Args struct { Dependencies []Dependency `json:"dependencies"` } func UpdateDependencyFile(args *Args) (interface{}, error) { data, err := ioutil.ReadFile("go.mod") if err != nil { return nil, err } f, err := modfile.Parse("go.mod", data, nil) if err != nil { return nil, err } for _, dep := range args.Dependencies { f.AddRequire(dep.Name, dep.Version) } for _, r := range f.Require { for _, dep := range args.Dependencies { if r.Mod.Path == dep.Name { setIndirect(r.Syntax, dep.Indirect) } } } f.SortBlocks() f.Cleanup() newModFile, _ := f.Format() return string(newModFile), nil }
Version data entries
696 entries across 696 versions & 2 rubygems