Commit a810ae3b authored by 魏灿's avatar 魏灿

文件关闭fix

parent 5c4eb808
...@@ -2,7 +2,6 @@ package tools ...@@ -2,7 +2,6 @@ package tools
import ( import (
"bufio" "bufio"
"log"
"os" "os"
"strings" "strings"
) )
...@@ -12,11 +11,7 @@ func HostsToJson() (data map[string][]string, err error) { ...@@ -12,11 +11,7 @@ func HostsToJson() (data map[string][]string, err error) {
if err != nil { if err != nil {
return nil, err return nil, err
} }
defer func() { defer f.Close()
if err = f.Close(); err != nil {
log.Fatal(err)
}
}()
data = make(map[string][]string) data = make(map[string][]string)
// 以这个文件为参数,创建一个 scanner // 以这个文件为参数,创建一个 scanner
s := bufio.NewScanner(f) 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