Skip to content
This repository has been archived by the owner on Nov 19, 2020. It is now read-only.

Generate windows syscalls using go generate #20

Open
justenwalker opened this issue Oct 8, 2019 · 0 comments
Open

Generate windows syscalls using go generate #20

justenwalker opened this issue Oct 8, 2019 · 0 comments
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@justenwalker
Copy link
Contributor

Use go generate tool to generate windows syscalls instead of writing them out manually.
This will help with maintainability

//go:generate go run golang.org/x/sys/windows/mkwinsyscall -output zsyscall_windows.go syscall_windows.go

Suggestion from #18 (comment) by @zx2c4 with details and examples

By the way, there's an easier way of dealing with all this using //sys. Check it out:

In this file (or in any file, really), I define a bunch of calls like this one:

https://github.com/WireGuard/wireguard-windows/blob/3f40da2044fd468ed05f3902608e62382b81ec9c/tunnel/firewall/syscall_windows.go#L14-L15

And then in this file, I have a go generate directive:

https://github.com/WireGuard/wireguard-windows/blob/3f40da2044fd468ed05f3902608e62382b81ec9c/tunnel/firewall/mksyscall.go#L8

Which winds up creating a file containing the fuction, like:

https://github.com/WireGuard/wireguard-windows/blob/3f40da2044fd468ed05f3902608e62382b81ec9c/tunnel/firewall/zsyscall_windows.go#L39-L52

https://github.com/WireGuard/wireguard-windows/blob/3f40da2044fd468ed05f3902608e62382b81ec9c/tunnel/firewall/zsyscall_windows.go#L90-L100

@justenwalker justenwalker added enhancement New feature or request good first issue Good for newcomers labels Oct 8, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

1 participant