From 4c565a5561e33e1d488116ea45c35d3ce408cf93 Mon Sep 17 00:00:00 2001 From: rlanhellas Date: Mon, 31 Jan 2022 22:47:42 +0000 Subject: [PATCH] time: return ENOENT instead of ERROR_PATH_NOT_FOUND in windows When using windows some users got a weird error (File not found) when the timezone database is not found. It happens because some methods in the time package don't treat ERROR_PATH_NOT_FOUND and ENOTDIR. To solve it was added a conversion to ENOTENT error. Fixes #50248 Change-Id: I11c84cf409e01eafb932aea43c7293c8218259b8 GitHub-Last-Rev: fe7fff90cbea06c4af41e5b2ecadea0d409e2c05 GitHub-Pull-Request: golang/go#50906 Reviewed-on: https://go-review.googlesource.com/c/go/+/381957 TryBot-Result: Gopher Robot Run-TryBot: Ian Lance Taylor Reviewed-by: David Chase Reviewed-by: Ian Lance Taylor Auto-Submit: Ian Lance Taylor --- src/time/sys_windows.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/time/sys_windows.go b/src/time/sys_windows.go index 481aea562e..78e182d4c5 100644 --- a/src/time/sys_windows.go +++ b/src/time/sys_windows.go @@ -16,6 +16,10 @@ func interrupt() { func open(name string) (uintptr, error) { fd, err := syscall.Open(name, syscall.O_RDONLY, 0) if err != nil { + // This condition solves issue https://go.dev/issue/50248 + if err == syscall.ERROR_PATH_NOT_FOUND { + err = syscall.ENOENT + } return 0, err } return uintptr(fd), nil -- 2.50.0