On some platforms (android, wasip1) this function is called many
times which probably results in some slowdown, especially for wasip1.
Wrap it into sync.OnceValues.
Change-Id: Id290ffd8d1e7ad806302f457e8fff2e3123b49a5
Reviewed-on: https://go-review.googlesource.com/c/go/+/609418
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
"os"
"path/filepath"
"runtime"
+ "sync"
)
-func hasSymlink() (ok bool, reason string) {
+var hasSymlink = sync.OnceValues(func() (ok bool, reason string) {
switch runtime.GOOS {
case "plan9":
return false, ""
}
return true, ""
-}
+})