]> Cypherpunks repositories - gostls13.git/commitdiff
os: simplify windows Getwd (fixes build)
authorAlex Brainman <alex.brainman@gmail.com>
Fri, 8 Aug 2014 00:09:31 +0000 (10:09 +1000)
committerAlex Brainman <alex.brainman@gmail.com>
Fri, 8 Aug 2014 00:09:31 +0000 (10:09 +1000)
Current version of Getwd calls Stat that
calls Getwd therefore infinite recursion.

LGTM=minux
R=golang-codereviews, minux
CC=golang-codereviews
https://golang.org/cl/119600043

src/pkg/os/getwd.go

index eacb414660ac8e74b3c04bc4e90b80a094cbc64c..d5da53b34bfa429ca2bc9ff02370a2481bf4dc7d 100644 (file)
@@ -5,6 +5,7 @@
 package os
 
 import (
+       "runtime"
        "sync"
        "syscall"
 )
@@ -23,6 +24,10 @@ var useSyscallwd = func(error) bool { return true }
 // reached via multiple paths (due to symbolic links),
 // Getwd may return any one of them.
 func Getwd() (dir string, err error) {
+       if runtime.GOOS == "windows" {
+               return syscall.Getwd()
+       }
+
        // Clumsy but widespread kludge:
        // if $PWD is set and matches ".", use it.
        dot, err := Stat(".")