Skip to content

Instantly share code, notes, and snippets.

@owainlewis
Created August 2, 2018 13:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save owainlewis/001ecce56983aaa7a85570ed0d9ab515 to your computer and use it in GitHub Desktop.
Save owainlewis/001ecce56983aaa7a85570ed0d9ab515 to your computer and use it in GitHub Desktop.
Legal deps stuff
cat Godeps/Godeps.json | jq '.Deps[] | "\(.ImportPath) \(.Rev)"'
package main
import (
"fmt"
"io/ioutil"
"os"
"path/filepath"
"strings"
)
const RESULTS = "results.txt"
func writeLicenseFile(path string) error {
contents, err := ioutil.ReadFile(path)
if err != nil {
return err
}
f, err := os.OpenFile(RESULTS, os.O_APPEND|os.O_WRONLY, 0600)
if err != nil {
return err
}
defer f.Close()
if _, err = f.WriteString(string(contents) + "\n\n"); err != nil {
return err
}
fmt.Printf("Write File name %s\n", f.Name())
return nil
}
func walkLicenses(searchdir string) error {
err := filepath.Walk(searchdir, func(path string, f os.FileInfo, err error) error {
if !f.IsDir() && strings.Contains(f.Name(), "LICENSE") {
err := writeLicenseFile(path)
if err != nil {
fmt.Printf("Error: %s", err)
}
}
return nil
})
return err
}
func main() {
walkLicenses("vendor")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment