From 38c3a87dd2c4a919e6cf019eb2e487f1bd5ad890 Mon Sep 17 00:00:00 2001 From: Kevin Offet Date: Sun, 9 Apr 2023 16:51:19 -0400 Subject: [PATCH] - .gitignore from sample dirs, create via template --- data-strings.go | 16 ++++++++++++++++ main.go | 8 ++++++++ 2 files changed, 24 insertions(+) diff --git a/data-strings.go b/data-strings.go index 0bc94e8..4e8d311 100644 --- a/data-strings.go +++ b/data-strings.go @@ -10,3 +10,19 @@ Usage examples: scaffold go NewGoProject scaffold py aPythonProject ` + +var gi_template = `%s +.env +*.env +.env.toml + +cfg/*.toml +cfg/.env +cfg/*.env +cfg/.env* +*.toml + +build/ +buildTime.txt +buildVersion.txt +` diff --git a/main.go b/main.go index 4d02024..486ff5a 100644 --- a/main.go +++ b/main.go @@ -176,6 +176,14 @@ func main() { _, err = exec.Command("git", "init").Output() ifFerr("Unable to initialize git repository", err) + nifd, err := os.Create(".gitignore") + ifFerr("Unable to create .gitignore file", err) + defer nifd.Close() + gi_content := fmt.Sprintf(gi_template, newProjectName) + _, err = nifd.WriteString(gi_content) + ifFerr("Unable to write .gitignore content", err) + fmt.Println("Wrote .gitignore content") + // stage files _, err = exec.Command("git", "add", ".").Output() ifFerr("Unable to stage files prior to first commit", err)