]> Cypherpunks repositories - gostls13.git/commitdiff
os: improve Getwd documentation
authorKir Kolyshkin <kolyshkin@gmail.com>
Wed, 21 Aug 2024 19:47:04 +0000 (12:47 -0700)
committerGopher Robot <gobot@golang.org>
Fri, 23 Aug 2024 00:53:47 +0000 (00:53 +0000)
1. Replace "rooted path name" with a more accurate "absolute path name".
Using "absolute" seems to be preferred terminology on Unix. On Windows,
there are multiple roots in Windows, thus "a rooted path name" can be
one relative to a drive letter or a server name. Note that Windows'
GetCurrentDirectory documentation [1] also says "the absolute path to the
current directory".

2. Add a note about using $PWD on Unix.

[1]: https://learn.microsoft.com/en-us/windows/win32/api/winbase/nf-winbase-getcurrentdirectory

Change-Id: Ic310f0f8776ff059544789306ae5cfa1fa267b12
Reviewed-on: https://go-review.googlesource.com/c/go/+/607615
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
src/os/getwd.go

index 64c3c4acd7e02e77c0421d641c1a6b7f3d5374bc..732ece7b098c0f1d9ad8649b9d2cf2c44518ebc3 100644 (file)
@@ -15,10 +15,14 @@ var getwdCache struct {
        dir string
 }
 
-// Getwd returns a rooted path name corresponding to the
+// Getwd returns an absolute path name corresponding to the
 // current directory. If the current directory can be
 // reached via multiple paths (due to symbolic links),
 // Getwd may return any one of them.
+//
+// On Unix platforms, if the environment variable PWD
+// provides an absolute name, and it is a name of the
+// current directory, it is returned.
 func Getwd() (dir string, err error) {
        if runtime.GOOS == "windows" || runtime.GOOS == "plan9" {
                dir, err = syscall.Getwd()