Commit a810ae3b authored by 魏灿's avatar 魏灿

文件关闭fix

parent 5c4eb808
......@@ -2,7 +2,6 @@ package tools
import (
"bufio"
"log"
"os"
"strings"
)
......@@ -12,11 +11,7 @@ func HostsToJson() (data map[string][]string, err error) {
if err != nil {
return nil, err
}
defer func() {
if err = f.Close(); err != nil {
log.Fatal(err)
}
}()
defer f.Close()
data = make(map[string][]string)
// 以这个文件为参数,创建一个 scanner
s := bufio.NewScanner(f)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment