Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.Sign up
x/sys/windows: GetLastError always returns nil #41220
What version of Go are you using (
The idea is that the error will be returned by the call, so you should never to call
So, if there is anything to do here, it's simply to document that there is no point to calling
What Ian said - do not call GetLastError directly from your code - Go runtime calls GetLastError for you behind the scenes.
It is pointless to call GetLastError from your Go code, because GetLastError changes every time you make new Windows API call. But Go runtime calls different Windows API at all times (for example to get memory or create threads). The fact that you don't see any Windows API calls in your code does not mean your program does not call Windows APIs.
Go runtime also changes threads all the time. GetLastError is thread specific. So, if you call GetLastError from your code, you might be getting GetLastError value from another unrelated thread.
On lines 70-73 this function gathers GetLastError value right after Windows API is finished. Just use that value.