From 23e46ff9c0d5a37d0dda0e417e048f6358faef82 Mon Sep 17 00:00:00 2001 From: Randy Date: Mon, 9 May 2022 17:15:17 +0800 Subject: [PATCH] fix windows file path issue --- process.go | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/process.go b/process.go index c18bbb8..3584bc4 100644 --- a/process.go +++ b/process.go @@ -6,7 +6,6 @@ import ( "io/ioutil" "log" "os" - "path" "path/filepath" "strings" ) @@ -37,20 +36,20 @@ func ParseSnpFiles() []byte { cwd, _ := os.Getwd() snippet := make(map[string]snippetItem) - err := filepath.Walk(cwd, func(filePath string, info os.FileInfo, err error) error { + err := filepath.Walk(cwd, func(fp string, info os.FileInfo, err error) error { if err != nil { return err } - if strings.HasSuffix(filePath, ".snp") { + if strings.HasSuffix(fp, ".snp") { attribute := attr{} - rawContent, readFileErr := ioutil.ReadFile(filePath) + rawContent, readFileErr := ioutil.ReadFile(fp) if readFileErr != nil { log.Fatal(err) } - filename := path.Base(filePath) + filename := filepath.Base(fp) prefix := filename[0 : len(filename)-4] content, parseFmErr := Unmarshal(rawContent, &attribute)