MCPcopy Index your code
hub / github.com/devploit/nomore403 / parseFile

Function parseFile

cmd/api.go:81–106  ·  view source on GitHub ↗

parseFile reads a file given its filename and returns a list containing each of its lines.

(filename string)

Source from the content-addressed store, hash-verified

79
80// parseFile reads a file given its filename and returns a list containing each of its lines.
81func parseFile(filename string) ([]string, error) {
82 file, err := os.Open(filename)
83 if err != nil {
84 return nil, err
85 }
86 defer func(file *os.File) {
87 if err := file.Close(); err != nil {
88 log.Printf("Error closing file: %v", err)
89 }
90 }(file)
91
92 var lines []string
93 scanner := bufio.NewScanner(file)
94 for scanner.Scan() {
95 line := strings.TrimRight(scanner.Text(), "\r")
96 if line == "" {
97 continue
98 }
99 lines = append(lines, line)
100 }
101 if err := scanner.Err(); err != nil {
102 return nil, err
103 }
104
105 return lines, nil
106}
107
108// header represents an HTTP header.
109type header struct {

Callers 7

requestMethodsFunction · 0.85
requestHeadersFunction · 0.85
requestEndPathsFunction · 0.85
requestMidPathsFunction · 0.85
requestPayloadPositionsFunction · 0.85

Calls

no outgoing calls

Tested by 1