Browse Source

lint windows

Michael Yang 11 tháng trước cách đây
mục cha
commit
e919f6811f

+ 4 - 2
app/lifecycle/server_windows.go

@@ -24,7 +24,8 @@ func terminate(cmd *exec.Cmd) error {
 	if err != nil {
 	if err != nil {
 		return err
 		return err
 	}
 	}
-	defer dll.Release() // nolint: errcheck
+	//nolint:errcheck
+	defer dll.Release()
 
 
 	pid := cmd.Process.Pid
 	pid := cmd.Process.Pid
 
 
@@ -73,7 +74,8 @@ func isProcessExited(pid int) (bool, error) {
 	if err != nil {
 	if err != nil {
 		return false, fmt.Errorf("failed to open process: %v", err)
 		return false, fmt.Errorf("failed to open process: %v", err)
 	}
 	}
-	defer windows.CloseHandle(hProcess) // nolint: errcheck
+	//nolint:errcheck
+	defer windows.CloseHandle(hProcess)
 
 
 	var exitCode uint32
 	var exitCode uint32
 	err = windows.GetExitCodeProcess(hProcess, &exitCode)
 	err = windows.GetExitCodeProcess(hProcess, &exitCode)

+ 2 - 3
app/tray/wintray/eventloop.go

@@ -47,7 +47,6 @@ func nativeLoop() {
 		default:
 		default:
 			pTranslateMessage.Call(uintptr(unsafe.Pointer(m))) //nolint:errcheck
 			pTranslateMessage.Call(uintptr(unsafe.Pointer(m))) //nolint:errcheck
 			pDispatchMessage.Call(uintptr(unsafe.Pointer(m)))  //nolint:errcheck
 			pDispatchMessage.Call(uintptr(unsafe.Pointer(m)))  //nolint:errcheck
-
 		}
 		}
 	}
 	}
 }
 }
@@ -160,8 +159,8 @@ func (t *winTray) wndProc(hWnd windows.Handle, message uint32, wParam, lParam ui
 		lResult, _, _ = pDefWindowProc.Call(
 		lResult, _, _ = pDefWindowProc.Call(
 			uintptr(hWnd),
 			uintptr(hWnd),
 			uintptr(message),
 			uintptr(message),
-			uintptr(wParam),
-			uintptr(lParam),
+			wParam,
+			lParam,
 		)
 		)
 	}
 	}
 	return
 	return

+ 3 - 7
app/tray/wintray/tray.go

@@ -186,7 +186,7 @@ func (t *winTray) initInstance() error {
 	t.muNID.Lock()
 	t.muNID.Lock()
 	defer t.muNID.Unlock()
 	defer t.muNID.Unlock()
 	t.nid = &notifyIconData{
 	t.nid = &notifyIconData{
-		Wnd:             windows.Handle(t.window),
+		Wnd:             t.window,
 		ID:              100,
 		ID:              100,
 		Flags:           NIF_MESSAGE,
 		Flags:           NIF_MESSAGE,
 		CallbackMessage: t.wmSystrayMessage,
 		CallbackMessage: t.wmSystrayMessage,
@@ -197,7 +197,6 @@ func (t *winTray) initInstance() error {
 }
 }
 
 
 func (t *winTray) createMenu() error {
 func (t *winTray) createMenu() error {
-
 	menuHandle, _, err := pCreatePopupMenu.Call()
 	menuHandle, _, err := pCreatePopupMenu.Call()
 	if menuHandle == 0 {
 	if menuHandle == 0 {
 		return err
 		return err
@@ -246,7 +245,7 @@ func (t *winTray) addOrUpdateMenuItem(menuItemId uint32, parentId uint32, title
 	mi := menuItemInfo{
 	mi := menuItemInfo{
 		Mask:     MIIM_FTYPE | MIIM_STRING | MIIM_ID | MIIM_STATE,
 		Mask:     MIIM_FTYPE | MIIM_STRING | MIIM_ID | MIIM_STATE,
 		Type:     MFT_STRING,
 		Type:     MFT_STRING,
-		ID:       uint32(menuItemId),
+		ID:       menuItemId,
 		TypeData: titlePtr,
 		TypeData: titlePtr,
 		Cch:      uint32(len(title)),
 		Cch:      uint32(len(title)),
 	}
 	}
@@ -302,11 +301,10 @@ func (t *winTray) addOrUpdateMenuItem(menuItemId uint32, parentId uint32, title
 }
 }
 
 
 func (t *winTray) addSeparatorMenuItem(menuItemId, parentId uint32) error {
 func (t *winTray) addSeparatorMenuItem(menuItemId, parentId uint32) error {
-
 	mi := menuItemInfo{
 	mi := menuItemInfo{
 		Mask: MIIM_FTYPE | MIIM_ID | MIIM_STATE,
 		Mask: MIIM_FTYPE | MIIM_ID | MIIM_STATE,
 		Type: MFT_SEPARATOR,
 		Type: MFT_SEPARATOR,
-		ID:   uint32(menuItemId),
+		ID:   menuItemId,
 	}
 	}
 
 
 	mi.Size = uint32(unsafe.Sizeof(mi))
 	mi.Size = uint32(unsafe.Sizeof(mi))
@@ -426,7 +424,6 @@ func iconBytesToFilePath(iconBytes []byte) (string, error) {
 // Loads an image from file and shows it in tray.
 // Loads an image from file and shows it in tray.
 // Shell_NotifyIcon: https://msdn.microsoft.com/en-us/library/windows/desktop/bb762159(v=vs.85).aspx
 // Shell_NotifyIcon: https://msdn.microsoft.com/en-us/library/windows/desktop/bb762159(v=vs.85).aspx
 func (t *winTray) setIcon(src string) error {
 func (t *winTray) setIcon(src string) error {
-
 	h, err := t.loadIconFrom(src)
 	h, err := t.loadIconFrom(src)
 	if err != nil {
 	if err != nil {
 		return err
 		return err
@@ -444,7 +441,6 @@ func (t *winTray) setIcon(src string) error {
 // Loads an image from file to be shown in tray or menu item.
 // Loads an image from file to be shown in tray or menu item.
 // LoadImage: https://msdn.microsoft.com/en-us/library/windows/desktop/ms648045(v=vs.85).aspx
 // LoadImage: https://msdn.microsoft.com/en-us/library/windows/desktop/ms648045(v=vs.85).aspx
 func (t *winTray) loadIconFrom(src string) (windows.Handle, error) {
 func (t *winTray) loadIconFrom(src string) (windows.Handle, error) {
-
 	// Save and reuse handles of loaded images
 	// Save and reuse handles of loaded images
 	t.muLoadedImages.RLock()
 	t.muLoadedImages.RLock()
 	h, ok := t.loadedImages[src]
 	h, ok := t.loadedImages[src]

+ 1 - 1
gpu/amd_windows.go

@@ -65,7 +65,7 @@ func AMDGetGPUInfo() []GpuInfo {
 
 
 	slog.Debug("detected hip devices", "count", count)
 	slog.Debug("detected hip devices", "count", count)
 	// TODO how to determine the underlying device ID when visible devices is causing this to subset?
 	// TODO how to determine the underlying device ID when visible devices is causing this to subset?
-	for i := 0; i < count; i++ {
+	for i := range count {
 		err = hl.HipSetDevice(i)
 		err = hl.HipSetDevice(i)
 		if err != nil {
 		if err != nil {
 			slog.Warn("set device", "id", i, "error", err)
 			slog.Warn("set device", "id", i, "error", err)