Skip to content

Commit

Permalink
move the trimspace
Browse files Browse the repository at this point in the history
  • Loading branch information
davidnewhall committed Jul 4, 2024
1 parent 91d507b commit 2cb2aa3
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions filepath.go
Original file line number Diff line number Diff line change
Expand Up @@ -173,8 +173,8 @@ func (o *Opts) parseString(elem reflect.Value, name string) error {
return nil
}

// Save this parsed file to the output map.
o.output[name] = strings.TrimPrefix(value, o.Prefix)
// Save this parsed file to the output map. Remove the prefix and any enclosing whitespace.
o.output[name] = strings.TrimSpace(strings.TrimPrefix(value, o.Prefix))

data, err := readFile(o.output[name], o.MaxSize)
if err != nil {
Expand All @@ -195,7 +195,7 @@ func (o *Opts) parseString(elem reflect.Value, name string) error {
}

func readFile(filePath string, maxSize uint) (string, error) {
fOpen, err := os.OpenFile(strings.TrimSpace(filePath), os.O_RDONLY, 0)
fOpen, err := os.OpenFile(filePath, os.O_RDONLY, 0)
if err != nil {
return "", fmt.Errorf("opening file: %w", err)
}
Expand Down

0 comments on commit 2cb2aa3

Please sign in to comment.