Skip to content
Myr

Improving createLicenseFile function

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Also fixing typo in README example.

authored by Ian Walter · committed by Steve Francia · parent d811f40 · Browse files · 2 files+15 added−12 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

2 files+15 added−12 removed

  • other:+15 added−12 removed

2 files+15 added−12 removed

modified:cobra/cmd/init.go+14 added-11 removed
86 unmodified lines
87 createRootCmdFile()88}8990func createLicenseFile() {91 data := make(map[string]interface{})91 lic := getLicense()9293 // Try to remove the email address, if any94 data["copyright"] = strings.Split(copyrightLine(), " <")[0]93 // Don't bother writing a LICENSE file if there is no text.94 if lic.Text != "" {95 data := make(map[string]interface{})9696 data["appName"] = projectName()97 // Try to remove the email address, if any98 data["copyright"] = strings.Split(copyrightLine(), " <")[0]99100 data["appName"] = projectName()98 // Get license and generate the template from text and data.99 lic := getLicense()100 r, _ := templateToReader(lic.Text, data)101 buf := new(bytes.Buffer)102 buf.ReadFrom(r)103 if template := buf.String(); template != "" {104 err := writeTemplateToFile(ProjectPath(), "LICENSE", template, data)101102 // Generate license template from text and data.103 r, _ := templateToReader(lic.Text, data)104 buf := new(bytes.Buffer)105 buf.ReadFrom(r)106107 err := writeTemplateToFile(ProjectPath(), "LICENSE", buf.String(), data)108 _ = err109 // if err != nil {110 // er(err)111 // }
134 unmodified lines
modified:README.md+1 added-1 removed
238 unmodified lines
239```yaml240license:241 header: This file is part of {{ .appName }}.242 text: |243 {{ .Copyright }}243 {{ .copyright }}244245 This is my license. There are many like it, but this one is mine.246 My license is my best friend. It is my life. I must master it as I must247 master my life.
644 unmodified lines