Skip to content

Commit

Permalink
Fix linter
Browse files Browse the repository at this point in the history
Signed-off-by: Tamal Saha <[email protected]>
  • Loading branch information
tamalsaha committed Apr 14, 2021
1 parent bfdaf87 commit 280bb8d
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions hostfile_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -334,8 +334,14 @@ func UpdateHostsFile(path string, aliases []string) (bool, error) {

hasher := sha1.New()
for i := range aliases {
hasher.Write([]byte(aliases[i]))
hasher.Write([]byte("\n"))
_, err = hasher.Write([]byte(aliases[i]))
if err != nil {
return false, err
}
_, err = hasher.Write([]byte("\n"))
if err != nil {
return false, err
}
}
newHex := hex.EncodeToString(hasher.Sum(nil))
if curHex == newHex {
Expand All @@ -350,7 +356,7 @@ func UpdateHostsFile(path string, aliases []string) (bool, error) {

for i := range aliases {
out.WriteString(aliases[i])
out.WriteString("\n") // \n requires to satisfy bash read command
out.WriteString("\n") // \n required to satisfy bash read command
}

err = ioutil.WriteFile(path, out.Bytes(), 0644)
Expand Down

0 comments on commit 280bb8d

Please sign in to comment.