Sha256: 1c4fe260f7ecc084e16b13ade10c7da1d6144823deaa7ad26ab4dfe641c09d47
Contents?: true
Size: 647 Bytes
Versions: 18
Compression:
Stored size: 647 Bytes
Contents
require 'pre-commit/checks/plugin' module PreCommit module Checks class Go < Plugin def call(staged_files) staged_files = staged_files.grep(/\.go$/) return if staged_files.empty? errors = staged_files.map { |file| run_check(file) }.compact return if errors.empty? errors.join("\n") end def run_check(file) cmd = "gofmt -l #{file} 2>&1" result = %x[ #{cmd} ] cmd = "go build -o /dev/null #{file} 2>&1" result << %x[ #{cmd} ] end def self.description "Detects bad Go formatting and compiler errors" end end end end
Version data entries
18 entries across 18 versions & 1 rubygems