Skip to content

Commit

Permalink
supress verbose log
Browse files Browse the repository at this point in the history
  • Loading branch information
inabajunmr committed Jun 1, 2022
1 parent 32b5550 commit 47bcd12
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions config/configs.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ package config
import (
"bufio"
"errors"
"fmt"
"io/ioutil"
"io"
"log"
"os"
"path/filepath"
Expand All @@ -26,8 +25,7 @@ func ReadConfigs() (*AnyConfConfigs, error) {
staticConf := readStaticConfig()
r, _ = readConfig(staticConf, r)
localConf, err := readLocalConfig()
if err != nil {
fmt.Println(err)
if err != nil && err != io.EOF {
return r, nil
}
r, _ = readConfig(localConf, r)
Expand All @@ -45,7 +43,7 @@ func readConfig(rawConf string, conf *AnyConfConfigs) (*AnyConfConfigs, error) {
}
sline := strings.Split(line, " ")
if len(sline) != 2 {
return &AnyConfConfigs{}, errors.New("static/configs.txt is something wrong.")
return &AnyConfConfigs{}, errors.New("static/configs.txt is something wrong")
}
key := sline[0]
configPath := sline[1]
Expand Down Expand Up @@ -74,7 +72,7 @@ func readLocalConfig() (string, error) {
log.Fatal(err)
}
path := filepath.Join(conf, ".anyconf", "configs.txt")
bytes, err := ioutil.ReadFile(path)
bytes, err := os.ReadFile(path)
if err != nil {
return "", err
}
Expand All @@ -94,7 +92,7 @@ func readStaticConfig() string {
log.Fatal(err)
}
defer r.Close()
contents, err := ioutil.ReadAll(r)
contents, err := io.ReadAll(r)
if err != nil {
log.Fatal(err)
}
Expand All @@ -106,7 +104,7 @@ func readStaticConfig() string {
func (c AnyConfConfigs) Read(key string) (*AnyConfConfigs, error) {
// TODO partial match?
if c.children[key] == nil {
return nil, errors.New("No config is matched.")
return nil, errors.New("no config is matched")
}

return c.children[key], nil
Expand Down

0 comments on commit 47bcd12

Please sign in to comment.