github.com/cilium/cilium@v1.16.2/tools/licensegen/licensegen.go (about) 1 // SPDX-License-Identifier: Apache-2.0 2 // Copyright Authors of Cilium 3 4 package main 5 6 import ( 7 "fmt" 8 "log" 9 "os" 10 "path/filepath" 11 "strings" 12 ) 13 14 func main() { 15 err := filepath.Walk("./vendor", func(path string, _ os.FileInfo, _ error) error { 16 base := filepath.Base(path) 17 ext := filepath.Ext(base) 18 if stem := strings.TrimSuffix(base, ext); stem == "LICENSE" || stem == "COPYING" { 19 switch strings.TrimPrefix(strings.ToLower(ext), ".") { 20 case "", "code", "docs", "libyaml", "md", "txt": 21 fmt.Println("Name:", path) 22 lb, err := os.ReadFile(path) 23 if err != nil { 24 log.Fatal(err) 25 } 26 fmt.Println("License:", string(lb)) 27 } 28 } 29 return nil 30 }) 31 if err != nil { 32 log.Fatal(err) 33 } 34 }