Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

proposal: x/sys/windows: Add ergonomic API for EnumProcesses #60289

Closed
roman-mazur opened this issue May 18, 2023 · 3 comments
Closed

proposal: x/sys/windows: Add ergonomic API for EnumProcesses #60289

roman-mazur opened this issue May 18, 2023 · 3 comments

Comments

@roman-mazur
Copy link

While fixing an issue (#60223) with the existing windows.EnumProcesses we had to introduce some manually written code wrapping what mkwinsyscall can generate and realized that the function signature we have is quite weird: it has *uint32 in its second parameter to return the number of bytes taken by the data added to the processIds slice.

It would be much more ergonomic to have an API that looks like

func EnumProcesses(processIds []uint32) (n int, err error)

where n has the number of items added to the input slice.

To keep backward compatibility, we would need to keep the old function and add a new one with a different name. So the final proposal is to add EnumProcs with the signature below and to mark EnumProcesses as deprecated.

func EnumProcs(processIds []uint32) (n int, err error)

I do have a need for this function, but am I alone?

@gopherbot gopherbot added this to the Proposal milestone May 18, 2023
@bcmills
Copy link
Contributor

bcmills commented May 18, 2023

(CC @golang/windows)

@alexbrainman
Copy link
Member

Thanks for your proposal @roman-mazur . But I would not add new API.

I don't believe golang.prg/x/sys/windows.EnumProcesses function is important enough to warrant two versions (version that matches Microsoft interface with "depreciated" tag and "ergonomic" version).

And personally I like golang.prg/x/sys/windows APIs that match Microsoft documentation. When using APIs, I always rely on Microsoft documentation. Microsoft Win32 APIs documentation is always very good.

Alex

@qmuntal
Copy link
Contributor

qmuntal commented May 29, 2023

Agree with what @alexbrainman. I don't think EnumProcesses is special enough to deserve a new API that differs from the one provided by Windows.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Incoming
Development

No branches or pull requests

5 participants