Use fmt.Errorf

This commit is contained in:
nemunaire 2020-04-15 07:39:38 +02:00
parent 45069d4fbb
commit adb424ea03
11 changed files with 50 additions and 60 deletions

View file

@ -2,7 +2,6 @@ package main
import (
"encoding/json"
"errors"
"fmt"
"io/ioutil"
"log"
@ -103,7 +102,7 @@ func genTeamIssuesFile(team fic.Team) error {
if s, err := os.Stat(dirPath); os.IsNotExist(err) {
os.MkdirAll(dirPath, 0777)
} else if !s.IsDir() {
return errors.New(fmt.Sprintf("%s is not a directory", dirPath))
return fmt.Errorf("%s is not a directory", dirPath)
}
if my, err := team.MyIssueFile(); err != nil {
@ -124,7 +123,7 @@ func genTeamMyFile(team *fic.Team) error {
if s, err := os.Stat(dirPath); os.IsNotExist(err) {
os.MkdirAll(dirPath, 0777)
} else if !s.IsDir() {
return errors.New(fmt.Sprintf("%s is not a directory", dirPath))
return fmt.Errorf("%s is not a directory", dirPath)
}
if my, err := fic.MyJSONTeam(team, true); err != nil {
@ -156,7 +155,7 @@ func genMyPublicFile() error {
if s, err := os.Stat(dirPath); os.IsNotExist(err) {
os.MkdirAll(dirPath, 0777)
} else if !s.IsDir() {
return errors.New(fmt.Sprintf("%s is not a directory", dirPath))
return fmt.Errorf("%s is not a directory", dirPath)
}
if my, err := fic.MyJSONTeam(nil, true); err != nil {
@ -237,7 +236,7 @@ func genAll() {
log.Println("Team retrieval error: ", err)
} else {
for _, team := range teams {
myteam := team // team is reused, we need to create a new variable here to store the value
myteam := team // team is reused, we need to create a new variable here to store the value
genTeamQueue <- &myteam
}
}