-
Notifications
You must be signed in to change notification settings - Fork 130
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #22 from piaolin/dev
pref: update output
- Loading branch information
Showing
7 changed files
with
105 additions
and
82 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package utils | ||
|
||
func AddTarget(targetList [][]string, targets chan []string) { | ||
for i := 0; i < len(targetList); i++ { | ||
targets <- targetList[i] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package utils | ||
|
||
import ( | ||
"bufio" | ||
"os" | ||
"strings" | ||
) | ||
|
||
func ParseResult(filename string) ([][]string, error) { | ||
f, err := os.Open(filename) | ||
if err != nil { | ||
return nil, err | ||
} | ||
defer f.Close() | ||
|
||
var resultList [][]string | ||
scanner := bufio.NewScanner(f) | ||
for scanner.Scan() { | ||
if scanner.Text() != "" { | ||
splitStr := strings.Split(scanner.Text(), ", ") | ||
resultList = append(resultList, splitStr) | ||
} | ||
} | ||
return resultList, err | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package utils | ||
|
||
import ( | ||
log "github.com/sirupsen/logrus" | ||
"os" | ||
"strings" | ||
"time" | ||
) | ||
|
||
func RenameFileByTime(filename string) (string, error) { | ||
if _, err := os.Stat(filename); err == nil { | ||
splitStr := strings.Split(filename, ".") | ||
newFileName := splitStr[0] + "_" + time.Now().Format("20060102_150405") + "." + splitStr[1] | ||
log.Debugln(newFileName) | ||
err := os.Rename(filename, newFileName) | ||
return newFileName, err | ||
} else { | ||
return filename, nil | ||
} | ||
} | ||
|
||
func RestoreFilename(filename string) error { | ||
if _, err := os.Stat(filename); err == nil { | ||
splitStr := strings.Split(filename, "_") | ||
fileExt := strings.Split(filename, ".") | ||
newFileName := splitStr[0] + "." + fileExt[len(fileExt)-1] | ||
log.Debugln(newFileName) | ||
return os.Rename(filename, newFileName) | ||
} else { | ||
return nil | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters