gitee.com/wgliang/goreporter@v0.0.0-20180902115603-df1b20f7c5d0/linters/golint/misc/emacs/golint.el (about)

     1  ;;; golint.el --- lint for the Go source code
     2  
     3  ;; Copyright 2013 The Go Authors. All rights reserved.
     4  ;; Use of this source code is governed by a BSD-style
     5  ;; license that can be found in the LICENSE file.
     6  
     7  ;; URL: https://github.com/golang/lint
     8  
     9  ;;; Commentary:
    10  
    11  ;; To install golint, add the following lines to your .emacs file:
    12  ;;   (add-to-list 'load-path "PATH CONTAINING golint.el" t)
    13  ;;   (require 'golint)
    14  ;;
    15  ;; After this, type M-x golint on Go source code.
    16  ;;
    17  ;; Usage:
    18  ;;   C-x `
    19  ;;     Jump directly to the line in your code which caused the first message.
    20  ;; 
    21  ;;   For more usage, see Compilation-Mode:
    22  ;;     http://www.gnu.org/software/emacs/manual/html_node/emacs/Compilation-Mode.html
    23  
    24  ;;; Code:
    25  (require 'compile)
    26  
    27  (defun go-lint-buffer-name (mode) 
    28   "*Golint*") 
    29  
    30  (defun golint-process-setup ()
    31    "Setup compilation variables and buffer for `golint'."
    32    (run-hooks 'golint-setup-hook))
    33  
    34  (define-compilation-mode golint-mode "golint"
    35    "Golint is a linter for Go source code."
    36    (set (make-local-variable 'compilation-scroll-output) nil)
    37    (set (make-local-variable 'compilation-disable-input) t)
    38    (set (make-local-variable 'compilation-process-setup-function)
    39         'golint-process-setup)
    40  )
    41  
    42  ;;;###autoload
    43  (defun golint ()
    44    "Run golint on the current file and populate the fix list. Pressing C-x ` will jump directly to the line in your code which caused the first message."
    45    (interactive)
    46    (compilation-start
    47     (mapconcat #'shell-quote-argument
    48                (list "golint" (expand-file-name buffer-file-name)) " ")
    49     'golint-mode))
    50  
    51  (provide 'golint)
    52  
    53  ;;; golint.el ends here