Skip to content

Commit

Permalink
Use json.NewDecoder instead of ioutil.ReadAll and json.Unmarshal (tha…
Browse files Browse the repository at this point in the history
…nks to @msimav)
  • Loading branch information
th0th committed Dec 13, 2020
1 parent f554573 commit 7913a66
Showing 1 changed file with 1 addition and 8 deletions.
9 changes: 1 addition & 8 deletions domain/domain.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package domain
import (
"encoding/json"
"fmt"
"io/ioutil"
"os"
)

Expand All @@ -20,15 +19,9 @@ func NewDomain() (*Domain, error) {
return nil, fmt.Errorf("an error occurred while opening the domains file: %v", err)
}

byteValue, err := ioutil.ReadAll(domainsJsonFile)

if err != nil {
return nil, fmt.Errorf("an error occurred while reading the domains file: %v", err)
}

var domainsSlice []string

err = json.Unmarshal(byteValue, &domainsSlice)
err = json.NewDecoder(domainsJsonFile).Decode(&domainsSlice)

if err != nil {
return nil, fmt.Errorf("an error occurred while parsing the domains file: %v", err)
Expand Down

0 comments on commit 7913a66

Please sign in to comment.