class Overcommit::Hook::PreCommit::GoVet

Runs `go vet` against any modified Golang files.

@see godoc.org/code.google.com/p/go-zh.tools/cmd/vet

Public Instance Methods

run() click to toggle source
# File lib/overcommit/hook/pre_commit/go_vet.rb, line 8
def run
  result = execute(command, args: applicable_files)
  return :pass if result.success?

  if result.stderr.match?(/no such tool "vet"/)
    return :fail, "`go tool vet` is not installed#{install_command_prompt}"
  end

  # example message:
  #   path/to/file.go:7: Error message
  extract_messages(
    result.stderr.split("\n"),
    /^(?<file>(?:\w:)?[^:]+):(?<line>\d+)/
  )
end