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

"go-staticcheck" cannot check #2069

Open
4 tasks
zsaw opened this issue Apr 9, 2024 · 0 comments
Open
4 tasks

"go-staticcheck" cannot check #2069

zsaw opened this issue Apr 9, 2024 · 0 comments

Comments

@zsaw
Copy link

zsaw commented Apr 9, 2024

Checklist

  • [☑️] I have searched existing issues and StackOverflow for solutions.
  • [☑️] I have read the [Flycheck manual][].
  • [☑️] I have read the [Troubleshooting Guide][].
  • [☑️] I have checked my issue has not been reported yet.

Problem description

"go-staticcheck" cannot check
The tmp method is not used, there should be a prompt
image

Steps to reproduce

Steps to reproduce the behavior:

  1. mkdir demo
  2. cd demo
  3. go mod init demo
  4. edit main.go file

Expected behavior

Prompt message "main.go:5:6: func tmp is unused (U1000)" in "Flycheck errors"

System configuration

Syntax checkers for buffer main.go in go-mode:

First checker to run:

  lsp (explicitly selected)
    - may enable: yes
    - may run:    t

Checkers that could run if selected:

  go-gofmt  select
    - may enable:    yes
    - executable:    Found at /usr/local/go/bin/gofmt
    - next checkers: go-vet, go-build, go-test, go-errcheck, go-unconvert, go-staticcheck

  go-vet  select
    - may enable:    yes
    - executable:    Found at /usr/local/go/bin/go
    - go tool vet:   present
    - next checkers: go-build, go-test, go-errcheck, go-unconvert, go-staticcheck

  go-build  select
    - may enable:    yes
    - may run:       t
    - executable:    Found at /usr/local/go/bin/go
    - next checkers: go-errcheck, go-unconvert, go-staticcheck

  go-errcheck  select
    - may enable:    yes
    - may run:       t
    - executable:    Found at /Users/johnwilson/go/bin/errcheck
    - next checkers: go-unconvert, go-staticcheck

  go-unconvert  select
    - may enable: yes
    - may run:    t
    - executable: Found at /Users/johnwilson/go/bin/unconvert

  go-staticcheck  select
    - may enable: yes
    - executable: Found at /Users/johnwilson/go/bin/staticcheck

Checkers that are compatible with this mode, but will not run until properly configured:

  go-test
    - may enable:    yes
    - may run:       nil
    - executable:    Found at /usr/local/go/bin/go
    - next checkers: go-errcheck, go-unconvert, go-staticcheck

Flycheck Mode is enabled.  Use C-u C-c ! x to enable disabled
checkers.

--------------------

Flycheck version: 34.1
Emacs version:    29.1
System:           aarch64-apple-darwin21.6.0
Window system:    ns

Emacs configuration:

  • [☑️] Plain Emacs / Custom configuration
  • Spacemacs
  • Doom Emacs
  • Prelude
  • Other shared configuration (please specify)

init.el

;;; init.el --- Emacs 配置文件
;;; Commentary:
;;; Code:

;; 打开配置文件
(defun open-init-file()
  (interactive)
  (find-file "~/.emacs.d/init.el"))

(setq inhibit-startup-message t)                                                 ; 禁用 启动消息
(setq initial-frame-alist '((top . 60) (left . 100) (width . 170) (height . 50))) ; 设置初始大小
(setq default-frame-alist '((width . 170) (height . 50)))                        ; 设置默认大小

(setq-default tab-width 4)
(defalias 'yes-or-no-p 'y-or-n-p)

(scroll-bar-mode -1)                 ; 禁用 滚动条模式
(tool-bar-mode -1)                   ; 禁用 工具栏模式
(tooltip-mode -1)                    ; 禁用 工具提示模式
(menu-bar-mode -1)                   ; 禁用 菜单栏模式
(global-display-line-numbers-mode 1) ; 启用 显示行号模式

(global-set-key (kbd "<f12>") 'open-init-file) ; 打开配置文件
(global-set-key (kbd "C-c R") 'restart-emacs)  ; 重启emacs

(require 'package)
(add-to-list 'package-archives '("MELPA Stable" . "https://stable.melpa.org/packages/") t)
(package-initialize) ; 初始化包
(unless package-archive-contents
  (package-refresh-contents)) ; 刷新包

(unless (package-installed-p 'use-package)
  (package-install 'use-package)) ; 安装 use-package

(require 'use-package)
(setq use-package-always-ensure t) ; 确保所有包可用

;; Emacs Nerd 字体图标库,需要安装 nerd fonts https://www.nerdfonts.com/font-downloads
;; https://melpa.org/#/nerd-icons
(use-package nerd-icons)

;; 简约而现代的模式行
;; https://melpa.org/#/doom-modeline
(use-package doom-modeline
  :ensure t
  :init (doom-modeline-mode 1))

;; 一组现代色彩主题
;; https://melpa.org/#/doom-themes
(use-package doom-themes
  :bind
  ;; ("C-c t" . counsel-load-theme)
  :config
  ;; (load-theme 'doom-gruvbox t)
  ;; (load-theme 'doom-tomorrow-night t)
  ;; (load-theme 'doom-rouge t)
  )

;; ivy 分为三个包:ivy、swiper和counsel; 通过安装counsel,另外两个将作为依赖项引入。
;; https://oremacs.com/swiper/#installing-from-emacs-package-manager
(use-package counsel
  :init
  (setq ivy-height '10)
  (setq ivy-use-virtual-buffers t)
  (setq ivy-count-format "(%d/%d)")
  :bind
  ("C-s" . swiper-isearch)
  ("M-x" . counsel-M-x)
  ("C-x C-f" . counsel-find-file)
  ("M-y" . counsel-yank-pop)
  ("C-x b" . ivy-switch-buffer)
  :config
  (ivy-mode 1))

;; 在弹出窗口中显示可用的按键绑定
;; https://elpa.gnu.org/packages/which-key.html
(use-package which-key
  :config (which-key-mode 1))

;; ivy 界面更加友好。
;; https://melpa.org/#/ivy-rich
(use-package ivy-rich
  :config (ivy-rich-mode 1))

;; 快速切换窗口
;; https://elpa.gnu.org/packages/ace-window.html
(use-package ace-window
  :bind ("C-x o" . ace-window))

;; 轻松管理和浏览 Emacs 中的项目
;; https://melpa.org/#/projectile
(use-package projectile
  :bind-keymap
  ("s-p" . projectile-command-map)
  :config (projectile-mode 1))

;; Emacs 中的 Git 瓷器
;; https://melpa.org/#/magit
(use-package magit)

;; Emacs 的另一个片段扩展
;; https://elpa.gnu.org/packages/yasnippet.html
(use-package yasnippet)

;; Go 编程语言的主要模式
;; https://melpa.org/#/go-mode
(use-package go-mode
  :hook (go-mode . lsp-deferred)
  (go-mode . yas-minor-mode))

;; 替代 Flymake
(use-package flycheck
  :ensure t
  :init (global-flycheck-mode)
  :config (setq-default flymake-mode nil))

;; LSP模式
;; https://melpa.org/#/lsp-mode
(use-package lsp-mode
  :commands (lsp lsp-deferred)
  :init
  (setq lsp-keymap-prefix "s-l")
  :config
  (setq lsp-headerline-breadcrumb-enable nil)
  :hook
  (lsp-mode . lsp-enable-which-key-integration)
  (before-save . lsp-format-buffer))

;; 模块化文本补全框架
;; https://elpa.gnu.org/packages/company.html
(use-package company
  :after lsp-mode
  :config
  (setq company-idle-delay 0)
  (setq company-minimum-prefix-length 1)
  :hook (prog-mode . company-mode))

;; https://melpa.org/#/lsp-ui
(use-package lsp-ui
  :config
  (setq lsp-ui-sideline-show-diagnostics t)  ; 在副线中显示诊断消息
  (setq lsp-ui-sideline-show-hover t)        ; 在边线显示悬停消息
  (setq lsp-ui-sideline-show-code-actions t) ; 在副线中显示代码操作
  (setq lsp-ui-sideline-delay 3)             ; 显示边线之前等待的秒数
  :hook (lsp-mode . lsp-ui-mode))

;; https://melpa.org/#/lsp-ivy
(use-package lsp-ivy)

;; https://melpa.org/#/dashboard
(use-package dashboard
  :init
  (dashboard-setup-startup-hook)
  :config
  (setq dashboard-items '((recents . 5) (projects . 5)))
  :bind ("<f5>" . dashboard-open))

;; 跳转到可见文本中的任意位置并快速选择文本
;; https://elpa.gnu.org/packages/avy.html
(use-package avy
  :bind
  ("C-;" . 'avy-goto-char)
  ("C-'" . 'avy-goto-char-2)
  ("M-g f" . 'avy-goto-line)
  ("M-g w" . 'avy-goto-word-1)
  ("M-g e" . 'avy-goto-word-0))

;; 使用 posframe 来显示 Ivy(ivy 显示在屏幕中间)
;; https://elpa.gnu.org/packages/ivy-posframe.html
(use-package ivy-posframe
  :config
  (setq ivy-posframe-display-functions-alist '((t . ivy-posframe-display-at-window-center)))
  (ivy-posframe-mode 1))

;; 一系列非常有用的扩展
;; https://melpa.org/#/crux
(use-package crux
  :bind
  ("C-j" . crux-top-join-line)                                    ; 连接行
  ("C-k" . crux-kill-whole-line)                                  ; 首先杀死行尾,然后杀死整行
  ("<S-return>" . crux-smart-open-line-above)                     ; 在当前行上方插入一个空行并正确缩进
  ("<C-return>" . crux-smart-open-line)                           ; 插入一个空行并正确缩进
  ("C-c d" . crux-duplicate-current-line-or-region)               ; 复制当前行(或区域)
  ("C-c M-d" . crux-duplicate-and-comment-current-line-or-region) ; 复制并注释当前行(或区域)
  )

(provide 'init)
;;; init.el ends here
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant