Skip to content

Commit

Permalink
Merge pull request #98 from zjj/master
Browse files Browse the repository at this point in the history
Fixed WriteFile and ReadFile
  • Loading branch information
Qianlitp authored Jun 7, 2022
2 parents 3218282 + b4f15ff commit 551acb2
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions pkg/tools/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ func ConvertHeaders(h map[string]interface{}) map[string]string {

func WriteFile(fileName string, content []byte) {
f, err := os.OpenFile(fileName, os.O_WRONLY|os.O_CREATE, 0644)
defer f.Close()
if err != nil {
fmt.Println(err.Error())
} else {
defer f.Close()
_, err = f.Write(content)
if err != nil {
logger.Logger.Error("write to file error ", err)
Expand All @@ -41,10 +41,10 @@ func WriteFile(fileName string, content []byte) {
func ReadFile(filePath string) []string {
filePaths := []string{}
f, err := os.OpenFile(filePath, os.O_RDONLY, 0644)
defer f.Close()
if err != nil {
fmt.Println(err.Error())
} else {
defer f.Close()
rd := bufio.NewReader(f)
for {
line, err := rd.ReadString('\n')
Expand Down

0 comments on commit 551acb2

Please sign in to comment.