1
0
mirror of https://github.com/golang/go synced 2024-11-12 09:30:25 -07:00

syscall: remove terminating \r and \n from windows error messages

R=rsc, peterGo
CC=golang-dev
https://golang.org/cl/3095042
This commit is contained in:
Alex Brainman 2010-12-13 17:02:01 +11:00
parent e04ef7769e
commit 84713d46f6

View File

@ -161,7 +161,10 @@ func Errstr(errno int) string {
if err != 0 {
return "error " + str(errno) + " (FormatMessage failed with err=" + str(err) + ")"
}
return string(utf16.Decode(b[0 : n-1]))
// trim terminating \r and \n
for ; n > 0 && (b[n-1] == '\n' || b[n-1] == '\r'); n-- {
}
return string(utf16.Decode(b[:n]))
}
func Exit(code int) { ExitProcess(uint32(code)) }