Skip to content

fileglob.Glob doesn't work with an absolute path on Windows #54

@rhysd

Description

@rhysd

Related to #19. I saw this comment. So I used filepath.ToSlash but it still doesn't work in this case.

Repro

Run the following code on Windows:

import (
  "fmt"
  "path/filepath"
  "github.com/goreleaser/fileglob"
)

func main() {
  x, err := fileglob.Glob(filepath.ToSlash(`C:\Windows`))
  if err != nil {
    panic(err)
  }
  fmt.Println(x)
}

Expected behavior

Since C:\Windows exists, it should print a slice with one element.

Actual behavior

It panicked with the following error:

stat static prefix ./C:/Windows: stat C:/Windows: invalid argument

filepath.ToSlash(`C:\Windows`) returns "C:/Windows". The function didn't seem to consider the C: drive letter and misunderstood that the path was relative.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions