Back up /etc/hosts and allow local changes
This commit is contained in:
@@ -11,6 +11,7 @@ import (
|
||||
"path/filepath"
|
||||
"regexp"
|
||||
"time"
|
||||
"bufio"
|
||||
// "strings"
|
||||
)
|
||||
|
||||
@@ -114,6 +115,20 @@ func IsFile(path string) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func ReadFile(path string) ([]string, error) {
|
||||
lines := []string{}
|
||||
f, err := os.Open(path)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
scanner := bufio.NewScanner(f)
|
||||
for scanner.Scan() {
|
||||
lines = append(lines, scanner.Text())
|
||||
}
|
||||
f.Close()
|
||||
return lines, nil
|
||||
}
|
||||
|
||||
func ValidString(pattern string, expr string) bool {
|
||||
if b, _ := regexp.MatchString(expr, pattern); b == true {
|
||||
return true
|
||||
|
||||
Reference in New Issue
Block a user