From 057113e989b2a75cf7f3ccbf6a1e4b25df9c7c15 Mon Sep 17 00:00:00 2001 From: Andrew Meissner Date: Thu, 10 Jan 2019 20:12:15 -0700 Subject: [PATCH 1/5] fixes for windows --- joe.go | 267 +++++++++++++++++++++++++++++-------------------------- utils.go | 16 ++-- 2 files changed, 151 insertions(+), 132 deletions(-) diff --git a/joe.go b/joe.go index 340a563..a5ce3a7 100644 --- a/joe.go +++ b/joe.go @@ -1,15 +1,16 @@ package main import ( - "fmt" - "github.com/codegangsta/cli" - "io/ioutil" - "log" - "os" - "path" - "path/filepath" - "sort" - "strings" + "fmt" + "io/ioutil" + "log" + "os" + "path/filepath" + "sort" + "strings" + + "github.com/codegangsta/cli" + homedir "github.com/mitchellh/go-homedir" ) const joe string = ` @@ -25,134 +26,150 @@ const joe string = ` ▐░░░░░░░▌ ▐░░░░░░░░░░░▌▐░░░░░░░░░░░▌ ▀▀▀▀▀▀▀ ▀▀▀▀▀▀▀▀▀▀▀ ▀▀▀▀▀▀▀▀▀▀▀ ` -const version string = "1.0.0" -const gitignoreUrl = "https://github.com/github/gitignore/archive/master.zip" -const dataDir string = ".joe-data" -var dataPath = path.Join(os.Getenv("HOME"), dataDir) +const ( + version = "1.1.0" + gitignoreURL = "https://github.com/github/gitignore/archive/master.zip" + dataDir = ".joe-data" +) + +var ( + homeDir string + dataPath string +) + +func init() { + home, err := homedir.Dir() + if err != nil { + log.Fatal(err) + } + + homeDir = home + dataPath = filepath.Join(homeDir, dataDir) +} func findGitignores() (a map[string]string, err error) { - _, err = ioutil.ReadDir(dataPath) - if err != nil { - return nil, err - } - - filelist := make(map[string]string) - filepath.Walk(dataPath, func(filepath string, info os.FileInfo, err error) error { - if strings.HasSuffix(info.Name(), ".gitignore") { - name := strings.ToLower(strings.Replace(info.Name(), ".gitignore", "", 1)) - filelist[name] = filepath - } - return nil - }) - return filelist, nil + _, err = ioutil.ReadDir(dataPath) + if err != nil { + return nil, err + } + + filelist := make(map[string]string) + filepath.Walk(dataPath, func(filepath string, info os.FileInfo, err error) error { + if strings.HasSuffix(info.Name(), ".gitignore") { + name := strings.ToLower(strings.Replace(info.Name(), ".gitignore", "", 1)) + filelist[name] = filepath + } + return nil + }) + return filelist, nil } func availableFiles() (a []string, err error) { - gitignores, err := findGitignores() - if err != nil { - return nil, err - } + gitignores, err := findGitignores() + if err != nil { + return nil, err + } - availableGitignores := []string{} - for key, _ := range gitignores { - availableGitignores = append(availableGitignores, key) - } + availableGitignores := []string{} + for key := range gitignores { + availableGitignores = append(availableGitignores, key) + } - return availableGitignores, nil + return availableGitignores, nil } func generate(args string) { - names := strings.Split(args, ",") - - gitignores, err := findGitignores() - if err != nil { - log.Fatal(err) - } - - notFound := []string{} - output := "" - for index, name := range names { - if filepath, ok := gitignores[strings.ToLower(name)]; ok { - bytes, err := ioutil.ReadFile(filepath) - if err == nil { - output += "\n#### " + name + " ####\n" - output += string(bytes) - if index < len(names) - 1 { - output += "\n" - } - continue - } - } else { - notFound = append(notFound, name) - } - } - - if len(notFound) > 0 { - fmt.Printf("Unsupported files: %s\n", strings.Join(notFound, ", ")) - fmt.Println("Run `joe ls` to see list of available gitignores.") - output = "" - } - if len(output) > 0 { - output = "#### joe made this: http://goel.io/joe\n" + output - } - fmt.Print(output) + names := strings.Split(args, ",") + + gitignores, err := findGitignores() + if err != nil { + log.Fatal(err) + } + + notFound := []string{} + output := "" + for index, name := range names { + if filepath, ok := gitignores[strings.ToLower(name)]; ok { + bytes, err := ioutil.ReadFile(filepath) + if err == nil { + output += "\n#### " + name + " ####\n" + output += string(bytes) + if index < len(names)-1 { + output += "\n" + } + continue + } + } else { + notFound = append(notFound, name) + } + } + + if len(notFound) > 0 { + fmt.Printf("Unsupported files: %s\n", strings.Join(notFound, ", ")) + fmt.Println("Run `joe ls` to see list of available gitignores.") + output = "" + } + if len(output) > 0 { + output = "#### joe made this: http://goel.io/joe\n" + output + } + fmt.Print(output) } func main() { - app := cli.NewApp() - app.Name = joe - app.Usage = "generate .gitignore files from the command line" - app.UsageText = "joe command [arguments...]" - app.Version = version - app.Commands = []cli.Command{ - { - Name: "ls", - Aliases: []string{"list"}, - Usage: "list all available files", - Action: func(c *cli.Context) error { - availableGitignores, err := availableFiles() - if err != nil { - log.Fatal(err) - return err - } - fmt.Printf("%d supported .gitignore files:\n", len(availableGitignores)) - sort.Strings(availableGitignores) - fmt.Printf("%s\n", strings.Join(availableGitignores, ", ")) - return nil - }, - }, - { - Name: "u", - Aliases: []string{"update"}, - Usage: "update all available gitignore files", - Action: func(c *cli.Context) error { - fmt.Println("Updating gitignore files..") - err := RemoveContents(dataPath) - if err != nil { - log.Fatal(err) - } - err = DownloadFiles(gitignoreUrl, dataPath) - if err != nil { - log.Fatal(err) - return err - } - return nil - }, - }, - { - Name: "g", - Aliases: []string{"generate"}, - Usage: "generate gitignore files", - Action: func(c *cli.Context) error { - if c.NArg() != 1 { - cli.ShowAppHelp(c) - } else { - generate(c.Args()[0]) - } - return nil - }, - }, - } - app.Run(os.Args) + app := cli.NewApp() + app.Name = joe + app.Usage = "generate .gitignore files from the command line" + app.UsageText = "joe command [arguments...]" + app.Version = version + app.Commands = []cli.Command{ + { + Name: "ls", + Aliases: []string{"list"}, + Usage: "list all available files", + Action: func(c *cli.Context) error { + availableGitignores, err := availableFiles() + if err != nil { + log.Fatal(err) + return err + } + fmt.Printf("%d supported .gitignore files:\n", len(availableGitignores)) + sort.Strings(availableGitignores) + fmt.Printf("%s\n", strings.Join(availableGitignores, ", ")) + return nil + }, + }, + { + Name: "u", + Aliases: []string{"update"}, + Usage: "update all available gitignore files", + Action: func(c *cli.Context) error { + fmt.Println("Updating gitignore files..") + err := removeContents(dataPath) + if err != nil { + log.Fatal(err) + } + err = downloadFiles(gitignoreURL, dataPath) + if err != nil { + log.Fatal(err) + return err + } + return nil + }, + }, + { + Name: "g", + Aliases: []string{"generate"}, + Usage: "generate gitignore files", + Action: func(c *cli.Context) error { + if c.NArg() != 1 { + cli.ShowAppHelp(c) + } else { + generate(c.Args()[0]) + } + return nil + }, + }, + } + app.Run(os.Args) } diff --git a/utils.go b/utils.go index 2915821..599bc1b 100644 --- a/utils.go +++ b/utils.go @@ -2,12 +2,12 @@ package main import ( "archive/zip" - "github.com/termie/go-shutil" "io" "net/http" "os" - "path" "path/filepath" + + shutil "github.com/termie/go-shutil" ) func unzip(archive, target string) (err error) { @@ -47,8 +47,10 @@ func unzip(archive, target string) (err error) { return nil } -func DownloadFiles(url string, dataPath string) (err error) { - archivePath := path.Join("/tmp", "master.zip") +func downloadFiles(url string, dataPath string) error { + tmpDir := os.TempDir() + + archivePath := filepath.Join(tmpDir, "master.zip") // Create the file out, err := os.Create(archivePath) @@ -71,12 +73,12 @@ func DownloadFiles(url string, dataPath string) (err error) { } // Unzip - err = unzip(archivePath, "/tmp") + err = unzip(archivePath, tmpDir) if err != nil { return err } - err = shutil.CopyTree(path.Join("/tmp", "gitignore-master"), dataPath, nil) + err = shutil.CopyTree(filepath.Join(tmpDir, "gitignore-master"), dataPath, nil) if err != nil { return err } @@ -84,7 +86,7 @@ func DownloadFiles(url string, dataPath string) (err error) { return nil } -func RemoveContents(dir string) (err error) { +func removeContents(dir string) (err error) { if _, err := os.Stat(dir); os.IsNotExist(err) { return nil } From f05018e07ba33e6711c4eb657b4303efcc25de22 Mon Sep 17 00:00:00 2001 From: Andrew Meissner Date: Mon, 20 Jul 2020 15:22:46 -0700 Subject: [PATCH 2/5] mod-ifying --- go.mod | 9 +++++++++ go.sum | 17 +++++++++++++++++ joe.go | 2 +- 3 files changed, 27 insertions(+), 1 deletion(-) create mode 100644 go.mod create mode 100644 go.sum diff --git a/go.mod b/go.mod new file mode 100644 index 0000000..1ac30d9 --- /dev/null +++ b/go.mod @@ -0,0 +1,9 @@ +module github.com/andrewmeissner/joe + +go 1.14 + +require ( + github.com/mitchellh/go-homedir v1.1.0 + github.com/termie/go-shutil v0.0.0-20140729215957-bcacb06fecae + github.com/urfave/cli v1.22.4 +) diff --git a/go.sum b/go.sum new file mode 100644 index 0000000..97e8820 --- /dev/null +++ b/go.sum @@ -0,0 +1,17 @@ +github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= +github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d h1:U+s90UTSYgptZMwQh2aRr3LuazLJIa+Pg3Kc1ylSYVY= +github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU= +github.com/mitchellh/go-homedir v1.1.0 h1:lukF9ziXFxDFPkA1vsr5zpc1XuPDn/wFntq5mG+4E0Y= +github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/russross/blackfriday/v2 v2.0.1 h1:lPqVAte+HuHNfhJ/0LC98ESWRz8afy9tM/0RK8m9o+Q= +github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= +github.com/shurcooL/sanitized_anchor_name v1.0.0 h1:PdmoCO6wvbs+7yrJyMORt4/BmY5IYyJwS/kOiWx8mHo= +github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc= +github.com/termie/go-shutil v0.0.0-20140729215957-bcacb06fecae h1:vgGSvdW5Lqg+I1aZOlG32uyE6xHpLdKhZzcTEktz5wM= +github.com/termie/go-shutil v0.0.0-20140729215957-bcacb06fecae/go.mod h1:quDq6Se6jlGwiIKia/itDZxqC5rj6/8OdFyMMAwTxCs= +github.com/urfave/cli v1.22.4 h1:u7tSpNPPswAFymm8IehJhy4uJMlUuU/GmqSkvJ1InXA= +github.com/urfave/cli v1.22.4/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= diff --git a/joe.go b/joe.go index a5ce3a7..c7096dd 100644 --- a/joe.go +++ b/joe.go @@ -9,8 +9,8 @@ import ( "sort" "strings" - "github.com/codegangsta/cli" homedir "github.com/mitchellh/go-homedir" + "github.com/urfave/cli" ) const joe string = ` From dc97d822e732e64e431e4b6bd73ce3964cd07ad1 Mon Sep 17 00:00:00 2001 From: Andrew Meissner Date: Mon, 20 Jul 2020 15:55:27 -0700 Subject: [PATCH 3/5] fixing sum file --- go.sum | 6 ------ joe.go | 4 ++-- 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/go.sum b/go.sum index 97e8820..fc18c41 100644 --- a/go.sum +++ b/go.sum @@ -1,15 +1,9 @@ github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= -github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d h1:U+s90UTSYgptZMwQh2aRr3LuazLJIa+Pg3Kc1ylSYVY= github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU= -github.com/mitchellh/go-homedir v1.1.0 h1:lukF9ziXFxDFPkA1vsr5zpc1XuPDn/wFntq5mG+4E0Y= github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= -github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/russross/blackfriday/v2 v2.0.1 h1:lPqVAte+HuHNfhJ/0LC98ESWRz8afy9tM/0RK8m9o+Q= github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= -github.com/shurcooL/sanitized_anchor_name v1.0.0 h1:PdmoCO6wvbs+7yrJyMORt4/BmY5IYyJwS/kOiWx8mHo= github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc= -github.com/termie/go-shutil v0.0.0-20140729215957-bcacb06fecae h1:vgGSvdW5Lqg+I1aZOlG32uyE6xHpLdKhZzcTEktz5wM= github.com/termie/go-shutil v0.0.0-20140729215957-bcacb06fecae/go.mod h1:quDq6Se6jlGwiIKia/itDZxqC5rj6/8OdFyMMAwTxCs= github.com/urfave/cli v1.22.4 h1:u7tSpNPPswAFymm8IehJhy4uJMlUuU/GmqSkvJ1InXA= github.com/urfave/cli v1.22.4/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0= diff --git a/joe.go b/joe.go index c7096dd..5b21c78 100644 --- a/joe.go +++ b/joe.go @@ -122,7 +122,7 @@ func main() { app.Usage = "generate .gitignore files from the command line" app.UsageText = "joe command [arguments...]" app.Version = version - app.Commands = []cli.Command{ + app.Commands = []*cli.Command{ { Name: "ls", Aliases: []string{"list"}, @@ -165,7 +165,7 @@ func main() { if c.NArg() != 1 { cli.ShowAppHelp(c) } else { - generate(c.Args()[0]) + generate(c.Args().First()) } return nil }, From df4c26ae15a7085a76c2e47af56ecb2b80faaabb Mon Sep 17 00:00:00 2001 From: Andrew Meissner Date: Sun, 24 Jan 2021 00:25:22 -0700 Subject: [PATCH 4/5] updating gomod --- go.mod | 4 ++-- go.sum | 10 ++++++++-- joe.go | 2 +- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/go.mod b/go.mod index 1ac30d9..b8c1719 100644 --- a/go.mod +++ b/go.mod @@ -1,9 +1,9 @@ module github.com/andrewmeissner/joe -go 1.14 +go 1.15 require ( github.com/mitchellh/go-homedir v1.1.0 github.com/termie/go-shutil v0.0.0-20140729215957-bcacb06fecae - github.com/urfave/cli v1.22.4 + github.com/urfave/cli v1.22.5 ) diff --git a/go.sum b/go.sum index fc18c41..df5e409 100644 --- a/go.sum +++ b/go.sum @@ -1,11 +1,17 @@ github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= +github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d h1:U+s90UTSYgptZMwQh2aRr3LuazLJIa+Pg3Kc1ylSYVY= github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU= +github.com/mitchellh/go-homedir v1.1.0 h1:lukF9ziXFxDFPkA1vsr5zpc1XuPDn/wFntq5mG+4E0Y= github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/russross/blackfriday/v2 v2.0.1 h1:lPqVAte+HuHNfhJ/0LC98ESWRz8afy9tM/0RK8m9o+Q= github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= +github.com/shurcooL/sanitized_anchor_name v1.0.0 h1:PdmoCO6wvbs+7yrJyMORt4/BmY5IYyJwS/kOiWx8mHo= github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc= +github.com/termie/go-shutil v0.0.0-20140729215957-bcacb06fecae h1:vgGSvdW5Lqg+I1aZOlG32uyE6xHpLdKhZzcTEktz5wM= github.com/termie/go-shutil v0.0.0-20140729215957-bcacb06fecae/go.mod h1:quDq6Se6jlGwiIKia/itDZxqC5rj6/8OdFyMMAwTxCs= -github.com/urfave/cli v1.22.4 h1:u7tSpNPPswAFymm8IehJhy4uJMlUuU/GmqSkvJ1InXA= -github.com/urfave/cli v1.22.4/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0= +github.com/urfave/cli v1.22.5 h1:lNq9sAHXK2qfdI8W+GRItjCEkI+2oR4d+MEHy1CKXoU= +github.com/urfave/cli v1.22.5/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= diff --git a/joe.go b/joe.go index 5b21c78..a3a095d 100644 --- a/joe.go +++ b/joe.go @@ -122,7 +122,7 @@ func main() { app.Usage = "generate .gitignore files from the command line" app.UsageText = "joe command [arguments...]" app.Version = version - app.Commands = []*cli.Command{ + app.Commands = []cli.Command{ { Name: "ls", Aliases: []string{"list"}, From f78ecd0d809aedef7e822f33fd7b662fba8da0c1 Mon Sep 17 00:00:00 2001 From: Andrew Meissner Date: Wed, 8 Nov 2023 12:34:21 -0700 Subject: [PATCH 5/5] fixing default branch name --- .gitignore | 15 +++++++++++++++ go.mod | 1 - go.sum | 2 -- joe.go | 9 +++------ utils.go | 2 +- 5 files changed, 19 insertions(+), 10 deletions(-) diff --git a/.gitignore b/.gitignore index 18324dc..d5ffa98 100644 --- a/.gitignore +++ b/.gitignore @@ -25,3 +25,18 @@ _testmain.go *.prof build/ +#### joe made this: http://goel.io/joe + +#### visualstudiocode #### +.vscode/* +!.vscode/settings.json +!.vscode/tasks.json +!.vscode/launch.json +!.vscode/extensions.json +!.vscode/*.code-snippets + +# Local History for Visual Studio Code +.history/ + +# Built Visual Studio Code Extensions +*.vsix diff --git a/go.mod b/go.mod index b8c1719..f3b518f 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,6 @@ module github.com/andrewmeissner/joe go 1.15 require ( - github.com/mitchellh/go-homedir v1.1.0 github.com/termie/go-shutil v0.0.0-20140729215957-bcacb06fecae github.com/urfave/cli v1.22.5 ) diff --git a/go.sum b/go.sum index df5e409..19e82ca 100644 --- a/go.sum +++ b/go.sum @@ -1,8 +1,6 @@ github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d h1:U+s90UTSYgptZMwQh2aRr3LuazLJIa+Pg3Kc1ylSYVY= github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU= -github.com/mitchellh/go-homedir v1.1.0 h1:lukF9ziXFxDFPkA1vsr5zpc1XuPDn/wFntq5mG+4E0Y= -github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/russross/blackfriday/v2 v2.0.1 h1:lPqVAte+HuHNfhJ/0LC98ESWRz8afy9tM/0RK8m9o+Q= diff --git a/joe.go b/joe.go index a3a095d..50cfffb 100644 --- a/joe.go +++ b/joe.go @@ -2,14 +2,12 @@ package main import ( "fmt" - "io/ioutil" "log" "os" "path/filepath" "sort" "strings" - homedir "github.com/mitchellh/go-homedir" "github.com/urfave/cli" ) @@ -39,17 +37,16 @@ var ( ) func init() { - home, err := homedir.Dir() + homeDir, err := os.UserHomeDir() if err != nil { log.Fatal(err) } - homeDir = home dataPath = filepath.Join(homeDir, dataDir) } func findGitignores() (a map[string]string, err error) { - _, err = ioutil.ReadDir(dataPath) + _, err = os.ReadDir(dataPath) if err != nil { return nil, err } @@ -91,7 +88,7 @@ func generate(args string) { output := "" for index, name := range names { if filepath, ok := gitignores[strings.ToLower(name)]; ok { - bytes, err := ioutil.ReadFile(filepath) + bytes, err := os.ReadFile(filepath) if err == nil { output += "\n#### " + name + " ####\n" output += string(bytes) diff --git a/utils.go b/utils.go index 599bc1b..aadb2ff 100644 --- a/utils.go +++ b/utils.go @@ -78,7 +78,7 @@ func downloadFiles(url string, dataPath string) error { return err } - err = shutil.CopyTree(filepath.Join(tmpDir, "gitignore-master"), dataPath, nil) + err = shutil.CopyTree(filepath.Join(tmpDir, "gitignore-main"), dataPath, nil) if err != nil { return err }