This is a bug in os.Getwd that causes it to return EOF as an error when the working directory no longer exists, on platforms that do not support syscall getwd . Here is a recurring test case of OS X.
package main import "os" import "fmt" const DIR = "/tmp/somedir" func main() { os.Remove(DIR) if err := os.Mkdir(DIR, 0755); err != nil { fmt.Println(err) return } if err := os.Chdir(DIR); err != nil { fmt.Println(err) return } if err := os.Remove(DIR); err != nil { fmt.Println(err) return } wd, err := os.Getwd() fmt.Println("err:", err) fmt.Println("wd:", wd) }
Output:
err: EOF wd:
source share