From 6a6d8fdcd30a65d6230891bc421be05db8c3a61f Mon Sep 17 00:00:00 2001 From: Peter Mundy Date: Wed, 21 Jul 2010 09:40:08 -0700 Subject: [PATCH] syscall: On Windows, Errstr FormatMessage has no values to insert. For the Windows version of syscall Errstr, set the FORMAT_MESSAGE_IGNORE_INSERTS value of the FormatMessage Flags argument when there are no values to insert. R=rsc, brainman CC=golang-dev https://golang.org/cl/1868043 --- src/pkg/syscall/syscall_windows.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/pkg/syscall/syscall_windows.go b/src/pkg/syscall/syscall_windows.go index a7f03add44..6aef0ded0e 100644 --- a/src/pkg/syscall/syscall_windows.go +++ b/src/pkg/syscall/syscall_windows.go @@ -142,8 +142,9 @@ func Errstr(errno int) string { if errno == EWINDOWS { return "not supported by windows" } + var flags uint32 = FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_ARGUMENT_ARRAY | FORMAT_MESSAGE_IGNORE_INSERTS b := make([]uint16, 300) - n, err := FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM|FORMAT_MESSAGE_ARGUMENT_ARRAY, 0, uint32(errno), 0, b, nil) + n, err := FormatMessage(flags, 0, uint32(errno), 0, b, nil) if err != 0 { return "error " + str(errno) + " (FormatMessage failed with err=" + str(err) + ")" } -- 2.48.1