MCPcopy
hub / github.com/jaeles-project/gospider / ReadingLines

Function ReadingLines

core/utils.go:179–203  ·  view source on GitHub ↗

ReadingLines Reading file and return content as []string

(filename string)

Source from the content-addressed store, hash-verified

177
178// ReadingLines Reading file and return content as []string
179func ReadingLines(filename string) []string {
180 var result []string
181 if strings.HasPrefix(filename, "~") {
182 filename, _ = homedir.Expand(filename)
183 }
184 file, err := os.Open(filename)
185 if err != nil {
186 return result
187 }
188 defer file.Close()
189
190 scanner := bufio.NewScanner(file)
191 for scanner.Scan() {
192 val := strings.TrimSpace(scanner.Text())
193 if val == "" {
194 continue
195 }
196 result = append(result, val)
197 }
198
199 if err := scanner.Err(); err != nil {
200 return result
201 }
202 return result
203}
204
205func contains(i []int,j int) bool {
206 for _, value := range i {

Callers 1

runFunction · 0.92

Calls 1

CloseMethod · 0.80

Tested by

no test coverage detected