Skip to content

Commit

Permalink
io: Address path input.json separator issue (#1203)
Browse files Browse the repository at this point in the history
When searching for an input.json file to use, the existing code will use
the path library, rather than filepath which is separator aware.

This causes issues on Windows where the path separator is \ and not /.

Signed-off-by: Charlie Egan <charlie@styra.com>
  • Loading branch information
charlieegan3 authored Oct 15, 2024
1 parent df4d44e commit 8504347
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions internal/io/io.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
files "io/fs"
"log"
"os"
"path"
"path/filepath"
"strings"

Expand Down Expand Up @@ -99,10 +98,10 @@ func ExcludeTestFilter() filter.LoaderFilter {
// both the location and the reader.
func FindInput(file string, workspacePath string) (string, io.Reader) {
relative := strings.TrimPrefix(file, workspacePath)
components := strings.Split(path.Dir(relative), string(filepath.Separator))
components := strings.Split(filepath.Dir(relative), string(filepath.Separator))

for i := range len(components) {
inputPath := path.Join(workspacePath, path.Join(components[:len(components)-i]...), "input.json")
inputPath := filepath.Join(workspacePath, filepath.Join(components[:len(components)-i]...), "input.json")

f, err := os.Open(inputPath)
if err == nil {
Expand Down

0 comments on commit 8504347

Please sign in to comment.