@@ -13,9 +13,10 @@ import (
13
13
"time"
14
14
"unsafe"
15
15
16
+ "golang.org/x/sys/windows"
17
+
16
18
"github.com/shirou/gopsutil/v4/internal/common"
17
19
"github.com/shirou/gopsutil/v4/process"
18
- "golang.org/x/sys/windows"
19
20
)
20
21
21
22
var (
@@ -79,7 +80,7 @@ func HostIDWithContext(ctx context.Context) (string, error) {
79
80
hostID := windows .UTF16ToString (regBuf [:])
80
81
hostIDLen := len (hostID )
81
82
if hostIDLen != uuidLen {
82
- return "" , fmt .Errorf ("HostID incorrect: %q\n " , hostID )
83
+ return "" , fmt .Errorf ("HostID incorrect: %q\n " , hostID ) //nolint:revive //FIXME
83
84
}
84
85
85
86
return strings .ToLower (hostID ), nil
@@ -135,15 +136,15 @@ func BootTimeWithContext(ctx context.Context) (uint64, error) {
135
136
return t , nil
136
137
}
137
138
138
- func PlatformInformationWithContext (ctx context.Context ) (platform string , family string , version string , err error ) {
139
- platform , family , _ , displayVersion , err := platformInformation (ctx )
139
+ func PlatformInformationWithContext (_ context.Context ) (platform string , family string , version string , err error ) {
140
+ platform , family , _ , displayVersion , err := platformInformation ()
140
141
if err != nil {
141
142
return "" , "" , "" , err
142
143
}
143
144
return platform , family , displayVersion , nil
144
145
}
145
146
146
- func platformInformation (ctx context. Context ) (platform , family , version , displayVersion string , err error ) {
147
+ func platformInformation () (platform , family , version , displayVersion string , err error ) {
147
148
// GetVersionEx lies on Windows 8.1 and returns as Windows 8 if we don't declare compatibility in manifest
148
149
// RtlGetVersion bypasses this lying layer and returns the true Windows version
149
150
// https://docs.microsoft.com/en-us/windows-hardware/drivers/ddi/content/wdm/nf-wdm-rtlgetversion
@@ -152,26 +153,26 @@ func platformInformation(ctx context.Context) (platform, family, version, displa
152
153
osInfo .dwOSVersionInfoSize = uint32 (unsafe .Sizeof (osInfo ))
153
154
ret , _ , err := procRtlGetVersion .Call (uintptr (unsafe .Pointer (& osInfo )))
154
155
if ret != 0 {
155
- return
156
+ return //nolint:nakedret //FIXME
156
157
}
157
158
158
159
// Platform
159
160
var h windows.Handle // like HostIDWithContext(), we query the registry using the raw windows.RegOpenKeyEx/RegQueryValueEx
160
161
err = windows .RegOpenKeyEx (windows .HKEY_LOCAL_MACHINE , windows .StringToUTF16Ptr (`SOFTWARE\Microsoft\Windows NT\CurrentVersion` ), 0 , windows .KEY_READ | windows .KEY_WOW64_64KEY , & h )
161
162
if err != nil {
162
- return
163
+ return //nolint:nakedret //FIXME
163
164
}
164
165
defer windows .RegCloseKey (h )
165
166
var bufLen uint32
166
167
var valType uint32
167
168
err = windows .RegQueryValueEx (h , windows .StringToUTF16Ptr (`ProductName` ), nil , & valType , nil , & bufLen )
168
169
if err != nil {
169
- return
170
+ return //nolint:nakedret //FIXME
170
171
}
171
172
regBuf := make ([]uint16 , bufLen / 2 + 1 )
172
173
err = windows .RegQueryValueEx (h , windows .StringToUTF16Ptr (`ProductName` ), nil , & valType , (* byte )(unsafe .Pointer (& regBuf [0 ])), & bufLen )
173
174
if err != nil {
174
- return
175
+ return //nolint:nakedret //FIXME
175
176
}
176
177
platform = windows .UTF16ToString (regBuf [:])
177
178
if strings .Contains (platform , "Windows 10" ) { // check build number to determine whether it's actually Windows 11
@@ -243,8 +244,8 @@ func VirtualizationWithContext(ctx context.Context) (string, string, error) {
243
244
return "" , "" , common .ErrNotImplementedError
244
245
}
245
246
246
- func KernelVersionWithContext (ctx context.Context ) (string , error ) {
247
- _ , _ , version , _ , err := platformInformation (ctx )
247
+ func KernelVersionWithContext (_ context.Context ) (string , error ) {
248
+ _ , _ , version , _ , err := platformInformation ()
248
249
return version , err
249
250
}
250
251
0 commit comments