libnetwork/etchosts: format code with gofumpt
Formatting the code with https://github.com/mvdan/gofumpt Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
parent
540e150e4e
commit
1cd937a867
1 changed files with 5 additions and 5 deletions
|
@ -106,7 +106,7 @@ func Build(path, IP, hostname, domainname string, extraContent []Record) error {
|
|||
}
|
||||
}
|
||||
|
||||
return os.WriteFile(path, content.Bytes(), 0644)
|
||||
return os.WriteFile(path, content.Bytes(), 0o644)
|
||||
}
|
||||
|
||||
// Add adds an arbitrary number of Records to an already existing /etc/hosts file
|
||||
|
@ -122,7 +122,7 @@ func Add(path string, recs []Record) error {
|
|||
return err
|
||||
}
|
||||
|
||||
return os.WriteFile(path, b, 0644)
|
||||
return os.WriteFile(path, b, 0o644)
|
||||
}
|
||||
|
||||
func mergeRecords(path string, recs []Record) ([]byte, error) {
|
||||
|
@ -187,7 +187,7 @@ loop:
|
|||
if err := s.Err(); err != nil {
|
||||
return err
|
||||
}
|
||||
return os.WriteFile(path, buf.Bytes(), 0644)
|
||||
return os.WriteFile(path, buf.Bytes(), 0o644)
|
||||
}
|
||||
|
||||
// Update all IP addresses where hostname matches.
|
||||
|
@ -201,6 +201,6 @@ func Update(path, IP, hostname string) error {
|
|||
if err != nil {
|
||||
return err
|
||||
}
|
||||
var re = regexp.MustCompile(fmt.Sprintf("(\\S*)(\\t%s)(\\s|\\.)", regexp.QuoteMeta(hostname)))
|
||||
return os.WriteFile(path, re.ReplaceAll(old, []byte(IP+"$2"+"$3")), 0644)
|
||||
re := regexp.MustCompile(fmt.Sprintf("(\\S*)(\\t%s)(\\s|\\.)", regexp.QuoteMeta(hostname)))
|
||||
return os.WriteFile(path, re.ReplaceAll(old, []byte(IP+"$2"+"$3")), 0o644)
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue