When I was first coding Abs, I wondered if people wouldn't
expect the path to be consistently clean, even if the path
passed in was already absolute.
CL
4524078 has a potential problem based on exactly that
assumption, so it feels like this behavior is indeed the
most useful and least surprising.
R=golang-dev, adg
CC=golang-dev
https://golang.org/cl/
4548074
// path name for a given file is not guaranteed to be unique.
func Abs(path string) (string, os.Error) {
if IsAbs(path) {
- return path, nil
+ return Clean(path), nil
}
wd, err := os.Getwd()
if err != nil {
// Already absolute
"$GOROOT/src/Make.pkg",
+ "$GOROOT/src/../src/Make.pkg",
}
func TestAbs(t *testing.T) {
if !filepath.IsAbs(abspath) {
t.Errorf("Abs(%q)=%q, not an absolute path", path, abspath)
}
+ if filepath.IsAbs(path) && abspath != filepath.Clean(path) {
+ t.Errorf("Abs(%q)=%q, isn't clean", path, abspath)
+ }
}
}