return formatMessage(flags, uintptr(msgsrc), msgid, langid, buf, args)
}
+var errnoErrorCache sync.Map
+
func (e Errno) Error() string {
// deal with special go errors
idx := int(e - APPLICATION_ERROR)
if 0 <= idx && idx < len(errors) {
return errors[idx]
}
+
+ cache := false
+ switch e {
+ case ERROR_FILE_NOT_FOUND, ERROR_PATH_NOT_FOUND:
+ if cached, ok := errnoErrorCache.Load(e); ok {
+ return cached.(string)
+ }
+ cache = true
+ }
+
+ result := e.error()
+ if cache {
+ errnoErrorCache.Store(e, result)
+ }
+ return result
+}
+
+func (e Errno) error() string {
// ask windows for the remaining errors
var flags uint32 = FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_ARGUMENT_ARRAY | FORMAT_MESSAGE_IGNORE_INSERTS
b := make([]uint16, 300)