mirror of
https://github.com/golang/go
synced 2024-11-21 21:44:40 -07:00
syscall: force Windows to always use US English error messages
Fixes #1834. R=rsc, alex.brainman CC=golang-dev https://golang.org/cl/5673068
This commit is contained in:
parent
d5b28ad2b6
commit
b17a233633
@ -77,6 +77,8 @@ func Getpagesize() int { return 4096 }
|
||||
// Errno is the Windows error number.
|
||||
type Errno uintptr
|
||||
|
||||
func langid(pri, sub uint16) uint32 { return uint32(sub)<<10 | uint32(pri) }
|
||||
|
||||
func (e Errno) Error() string {
|
||||
// deal with special go errors
|
||||
idx := int(e - APPLICATION_ERROR)
|
||||
@ -86,7 +88,7 @@ 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)
|
||||
n, err := FormatMessage(flags, 0, uint32(e), 0, b, nil)
|
||||
n, err := FormatMessage(flags, 0, uint32(e), langid(LANG_ENGLISH, SUBLANG_ENGLISH_US), b, nil)
|
||||
if err != nil {
|
||||
return "error " + itoa(int(e)) + " (FormatMessage failed with err=" + itoa(int(err.(Errno))) + ")"
|
||||
}
|
||||
|
@ -116,6 +116,9 @@ const (
|
||||
FILE_CURRENT = 1
|
||||
FILE_END = 2
|
||||
|
||||
LANG_ENGLISH = 0x09
|
||||
SUBLANG_ENGLISH_US = 0x01
|
||||
|
||||
FORMAT_MESSAGE_ALLOCATE_BUFFER = 256
|
||||
FORMAT_MESSAGE_IGNORE_INSERTS = 512
|
||||
FORMAT_MESSAGE_FROM_STRING = 1024
|
||||
|
Loading…
Reference in New Issue
Block a user