From b8275de8f131df31bb587acb26271dadcc14754b Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Fri, 23 Dec 2022 00:05:39 +0100 Subject: [PATCH] windows: export getProcessEntry This function is currently copied in github.com/inconshreveable/mousetrap, which is widely used in projects (commonly as dependency for spf13/cobra). Until recently, mousetrap had code for backward-compatibility with old Go versions, but now that that code was removed, it's a very small wrapper around getProcessEntry. Exporting this function allows it to be an even smaller wrapper (most projects would already have golang.org/x/sys as dependency in some form or another). --- windows/syscall_windows.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/windows/syscall_windows.go b/windows/syscall_windows.go index a49853e9d..dd05ca810 100644 --- a/windows/syscall_windows.go +++ b/windows/syscall_windows.go @@ -1390,7 +1390,7 @@ func FindNextFile(handle Handle, data *Win32finddata) (err error) { return } -func getProcessEntry(pid int) (*ProcessEntry32, error) { +func GetProcessEntry(pid int) (*ProcessEntry32, error) { snapshot, err := CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0) if err != nil { return nil, err @@ -1413,7 +1413,7 @@ func getProcessEntry(pid int) (*ProcessEntry32, error) { } func Getppid() (ppid int) { - pe, err := getProcessEntry(Getpid()) + pe, err := GetProcessEntry(Getpid()) if err != nil { return -1 }