GopherCon 2020: Justen Walker - Safety Not Guaranteed: Calling Windows APIs using Unsafe & Syscall

preview_player
Показать описание
It would be nice if we could solve all of our problems using pure Go. Unfortunately, sometimes this isn't possible; especially when it comes using Windows APIs.

Go gives us a set of tools to deal with some of the messier parts of reality: CGO and unsafe. However, "CGO is not Go", and as a Go developer, it should be your last option when given alternatives. It turns out that, for the most part, the unsafe and syscall packages are all you need to call Windows APIs.

You'll learn how to:

• Load DLLs and call their exported functions.
• Map C-like structs to Go-like structs.
• Convert results of Win32 API functions into Go types.
• Avoid some of the pitfalls of using the unsafe package.
Рекомендации по теме