MCPcopy Create free account
hub / github.com/code-scan/Goal / LinesInFile

Function LinesInFile

Gsensor/ksubdomain/util.go:27–42  ·  view source on GitHub ↗
(fileName string)

Source from the content-addressed store, hash-verified

25}
26
27func LinesInFile(fileName string) ([]string, error) {
28 result := []string{}
29 f, err := os.Open(fileName)
30 if err != nil {
31 return result, err
32 }
33 defer f.Close()
34 scanner := bufio.NewScanner(f)
35 for scanner.Scan() {
36 line := scanner.Text()
37 if line != "" {
38 result = append(result, line)
39 }
40 }
41 return result, nil
42}
43
44func FileExists(path string) bool {
45 _, err := os.Stat(path) //os.Stat获取文件信息

Callers

nothing calls this directly

Calls 2

TextMethod · 0.80
CloseMethod · 0.45

Tested by

no test coverage detected