From 6d6c92d5b776bb2b3ce840a973de4f76ccccc5b6 Mon Sep 17 00:00:00 2001 From: Anthony Fok Date: Sat, 21 Nov 2015 23:29:20 -0700 Subject: [PATCH] Parse the full license text as a template MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ... to allow including "Copyright © 2015 NAME HERE" to the output LICENSE file where necessary --- cobra/cmd/init.go | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/cobra/cmd/init.go b/cobra/cmd/init.go index 72a70d2..e3c0b45 100644 --- a/cobra/cmd/init.go +++ b/cobra/cmd/init.go @@ -16,6 +16,7 @@ package cmd import ( "fmt" "os" + "strings" "github.com/spf13/cobra" "github.com/spf13/viper" @@ -87,7 +88,16 @@ func initalizePath(path string) { func createLicenseFile() { lic := getLicense() - err := writeStringToFile(ProjectPath(), "LICENSE", lic.Text) + + template := lic.Text + + var data map[string]interface{} + data = make(map[string]interface{}) + + // Try to remove the email address, if any + data["copyright"] = strings.Split(copyrightLine(), " <")[0] + + err := writeTemplateToFile(ProjectPath(), "LICENSE", template, data) _ = err // if err != nil { // er(err)