github.com/henvic/wedeploycli@v1.7.6-0.20200319005353-3630f582f284/legal/extra/extra.go (about) 1 package extra 2 3 import ( 4 "fmt" 5 "io/ioutil" 6 ) 7 8 // License structure 9 type License struct { 10 Name string 11 Package string 12 Notes string 13 LicensePath string 14 } 15 16 // Get license 17 func (l *License) Get() ([]byte, error) { 18 var license, err = ioutil.ReadFile(l.LicensePath) 19 20 if err != nil { 21 return nil, err 22 } 23 24 var content = []byte(fmt.Sprintf("%s %s", l.Name, l.Package)) 25 26 if len(l.Notes) != 0 { 27 content = append(content, []byte(fmt.Sprintf(" (%s)", l.Notes))...) 28 } 29 30 content = append(content, "\n"...) 31 content = append(content, license...) 32 33 return content, nil 34 }