# Pastebin FtlvGRyI package main import ( "io/ioutil" "log" "os/exec" toml "github.com/pelletier/go-toml" ) const notice = "# This file is autogenerated, do not edit; changes may be undone by the next 'dep ensure'.\n\n" type gopkg struct { Projects []*project `toml:"projects"` Meta meta `toml:"solve-meta"` } type project struct { Name string `toml:"name"` Source *string `toml:"source,omitempty"` Version *string `toml:"version,omitempty"` Branch *string `toml:"branch,omitempty"` Revision *string `toml:"revision,omitempty"` Packages []string `toml:"packages,omitempty"` SHA256 *string `toml:"sha256,omitempty"` } type meta struct { AnalyzerName string `toml:"analyzer-name"` AnalyzerVersion uint `toml:"analyzer-version"` InputsDigest string `toml:"inputs-digest"` SolverName string `toml:"solver-name"` SolverVersion uint `toml:"solver-version"` } func main() { content, err := ioutil.ReadFile("Gopkg.lock") fail(err) pkgs := gopkg{} err = toml.Unmarshal(content, &pkgs) fail(err) for _, p := range pkgs.Projects { path := "vendor/" + p.Name cmd := exec.Command("nix-hash", "--type", "sha256", "--base32", path) out, err := cmd.Output() fail(err) sout := string(out[0 : len(out)-1]) p.SHA256 = &sout } buf, err := toml.Marshal(pkgs) fail(err) buf = append([]byte(notice), buf...) err = ioutil.WriteFile("Gopkg.lock", buf, 0644) fail(err) } func fail(err error) { if err != nil { log.Fatalln(err) } }