More information about the Go Meta Linter can be found here: https://github.com/alecthomas/gometalinter
To use that linter with Zeus do the following:
1) Download, build and install the Go code.
Code: Select all
go get github.com/alecthomas/gometalinter
Code: Select all
gometalinter --install
Installing structcheck -> go get github.com/opennota/check/cmd/structcheck
Installing vet -> go get golang.org/x/tools/cmd/vet
Installing deadcode -> go get github.com/remyoudompheng/go-misc/deadcode
Installing go-nyet -> go get github.com/barakmich/go-nyet
Installing golint -> go get github.com/golang/lint/golint
# github.com/golang/lint
..\..\golang\lint\lint.go:1401: assignment count mismatch: 3 = 2
gometalinter: error: failed to install golint: exit status 2
Installing errcheck -> go get github.com/alecthomas/errcheck
Installing varcheck -> go get github.com/opennota/check/cmd/varcheck
Installing gotype -> go get golang.org/x/tools/cmd/gotype
Installing defercheck -> go get github.com/opennota/check/cmd/defercheck
Installing gocyclo -> go get github.com/alecthomas/gocyclo
Code: Select all
--
-- Name: gometalinter Macro
--
-- Language: Lua Macro
--
-- Description: This macro will execute the gometalinter tool to check
-- the files in the current directory. To use this macro
-- open a file in the directory to be checked.
--
-- Project: https://github.com/alecthomas/gometalinter
--
local utils = require "utils"
function key_macro()
-- details about the active document
local document, named, read_only, document_type = utils.document_details()
if (document_type ~= "Go Document Type") or (document == 0) or (named == 0) then
message("This macro only works with named Go documents.")
beep()
return
end
-- the directory of the current document
local dir = macro_tag("$fdd")
message("Go is linting the code....")
-------------------------------------------------------------------------
-- usage: gometalinter [<flags>] [<path>]
------------------------------------------------------------------------
-- Flags:
-- --help Show help.
-- --fast Only run fast linters.
-- -i, --install Attempt to install all known linters.
-- -u, --update Pass -u to go tool when installing.
-- -D, --disable=LINTER
-- List of linters to disable.
-- -d, --debug Display messages for failed linters, etc.
-- -j, --concurrency=16
-- Number of concurrent linters to run.
-- --exclude=REGEXP Exclude messages matching this regular expression.
-- --cyclo-over="10" Report functions with cyclomatic complexity over N (using gocyclo).
-- --sort=none Sort output by any of none, path, line, column, severity, message.
-- --linter=NAME:COMMAND:PATTERN
-- Specify a linter.
-- --message-overrides=LINTER:MESSAGE
-- Override message from linter. {message} will be expanded to the original message.
-- --severity=LINTER:SEVERITY
-- Map of linter severities.
--
-- Args:
-- [<path>] Directory to lint.
------------------------------------------------------------------------
local cmd_options = "--fast"
-- build up the command
local cmd = "gometalinter.exe " .. cmd_options
-- for debugging only
--message_box(1, cmd, "Command Line")
-------------------------------------------------------------------------------
-- System Control Values
-------------------------------------------------------------------------------
-- 1 - save the document before running the program
-- 2 - capture any standard output generated by the program
-- 4 - capture any standard error generated by the program
-- 8 - ask for additional arguments
-- 16 - the program will use the MS-DOS command interpreter (ie. dir *.* etc)
-- 32 - wait for the program to complete (the ESC key will cancel the wait)
-- 64 - run the program in a visible DOS session (otherwise runs hidden)
-- 128 - capture output to a compler window (not the default tool window)
--
-------------------------------------------------------------------------------
-- Output Control Flags:
-------------------------------------------------------------------------------
-- 0 - ALWAYS
-- 1 - NEVER
-- 2 - ERRORS
-- 3 - WARNINGS
-- 4 - ANYOUTPUT
-------------------------------------------------------------------------------
-- display the window if any errors are generated
local ERRORS = 2
-- run with 'save', 'capture output' and 'wait' and 'compiler' options
local flags = 1+2+4+32+128
local caption = "gometalinter: " .. dir
if (system(cmd, dir, flags, caption, ERRORS) == 0) then
message("The linting of the directory is: " .. dir)
else
beep()
end
end
key_macro() -- run the macro
Code: Select all
stutter.go:8:1:warning: unusedGlobal is unused
stutter.go:12:1:warning: MyStruct is unused
stutter.go:16:1:warning: PublicUndocumented is unused
stutter.go:20:1:warning: duplicateDefer is unused
stutter.go:22::error: Repeating defer a.Close() inside function duplicateDefer
stutter.go:29::error: unreachable code
stutter.go:26::error: missing argument for Printf("%d"): format reads arg 1, have only 0 args
stutter.go:12:6:warning: exported type MyStruct should have comment or be unexported
stutter.go:16:6:warning: exported type PublicUndocumented should have comment or be unexported