]> Cypherpunks repositories - gostls13.git/commitdiff
os/user: note in doc that user.Current is being cached
authorDavid Heuschmann <heuschmann.d@gmail.com>
Wed, 19 Sep 2018 15:00:09 +0000 (17:00 +0200)
committerIan Lance Taylor <iant@golang.org>
Tue, 25 Sep 2018 17:10:46 +0000 (17:10 +0000)
user.Current caches the current user after its first call, so changes to
the uid after the first call will not affect its result. As this might
be unexpected, it should be mentioned in the docs.

Fixes #27659

Change-Id: I8b3323d55441d9a79bc9534c6490884d8561889b
Reviewed-on: https://go-review.googlesource.com/136315
Reviewed-by: Ian Lance Taylor <iant@golang.org>
src/os/user/lookup.go

index 2243a25788aed0bb65130d3227d62a1d056cb06f..b36b7c01c0b1c02437e4466e2aab689f4662ca8c 100644 (file)
@@ -7,6 +7,10 @@ package user
 import "sync"
 
 // Current returns the current user.
+//
+// The first call will cache the current user information.
+// Subsequent calls will return the cached value and will not reflect
+// changes to the current user.
 func Current() (*User, error) {
        cache.Do(func() { cache.u, cache.err = current() })
        if cache.err != nil {