Skip to content

path/filepath: Match does not use Glob patterns #41394

@vatine

Description

@vatine

What version of Go are you using (go version)?

$ go version
go version go1.14 linux/amd64

Does this issue reproduce with the latest release?

Based on docuemntation and the Go playground, yes. https://play.golang.org/p/WHq5MYYn_yf

What operating system and processor architecture are you using (go env)?

go env Output
$ go env
GO111MODULE="on"
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/ingvar/.cache/go-build"
GOENV="/home/ingvar/.config/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/home/ingvar/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/lib/go-1.14"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/lib/go-1.14/pkg/tool/linux_amd64"
GCCGO="gccgo"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/home/ingvar/go/src/go.mod"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build667987227=/tmp/go-build -gno-record-gcc-switches"

What did you do?

I passed the pattern "ga*[!k]" to filepath.Match expecting it to not match the string "gazonk" (as it clearly states it must match the entire pattern, and the glob-like syntax for a negated character class is [!...]). It turns out that filepath.Match actually uses regexp-like syntx for character classes.

https://play.golang.org/p/WHq5MYYn_yf

What did you expect to see?

I expected a function that says "shell file name pattern" to understand glob patterns. Especially since filepath.Glob says "uses the same pattern as Match".

What did you see instead?

I saw a function that partially uses glob patterns and partially (well, specifically for character classes) uses regexp patterns.

Metadata

Metadata

Assignees

No one assigned

    Labels

    FrozenDueToAgeNeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions