Skip to content

path/filepath: regression in EvalSymlinks wrt ending slash #29372

@kolyshkin

Description

@kolyshkin

Summary

In Go versions prior to 1.12-beta1, a call to filepath.EvalSymlinks() with an argument like "/path/to/existing/file/" results in no error and the trailing slash removed. With 1.12-beta1, it gives "file does not exist". Complete example here: https://play.golang.org/p/YmfDC5IcWMF

Whether the old behavior was deliberate or accidental, this looks like a regression.

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

$ go1.12beta1 version
go version go1.12beta1 linux/amd64

Does this issue reproduce with the latest release?

yes (beta)

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

go env Output
$ go1.12beta1 env
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/kir/.cache/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/kir/go"
GOPROXY=""
GORACE=""
GOROOT="/home/kir/sdk/go1.12beta1"
GOTMPDIR=""
GOTOOLDIR="/home/kir/sdk/go1.12beta1/pkg/tool/linux_amd64"
GCCGO="gccgo"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD=""
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-build989138565=/tmp/go-build -gno-record-gcc-switches"

What did you do?

	path, err := filepath.EvalSymlinks("/path/to/existing/file/")

Complete example: https://play.golang.org/p/YmfDC5IcWMF

What did you expect to see?

No error, trailing slash removed:

kir@kd:~/go/src/github.com/kolyshkin/test/go112$ go test -v .
=== RUN   TestEvalSymlinksWithEndingSlash
--- PASS: TestEvalSymlinksWithEndingSlash (0.00s)
PASS
ok  	github.com/kolyshkin/test/go112	0.001s

What did you see instead?

"file does not exist" error with no context:

kir@kd:~/go/src/github.com/kolyshkin/test/go112$ go1.12beta1 test -v .
=== RUN   TestEvalSymlinksWithEndingSlash
--- FAIL: TestEvalSymlinksWithEndingSlash (0.00s)
    filepath_test.go:23: file does not exist
FAIL
FAIL	github.com/kolyshkin/test/go112	0.001s

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

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions