-
git precommit hook for gofmt
It’s no surprise I like Ruby, and gofmt is a great idea I wish Ruby could enforce. Instead of forgetting to run it constantly, let’s have git run it. In your
.git/hooks/pre-commit:
Make sure you run#!/usr/bin/env ruby Dir["**/*.go"].each do |go| if File.basename(go) !~ /^_/ puts "gofmt #{go}" system("gofmt -w=true #{go} && git add #{go}") end endchmod a+xon that hook too. Also, this will mess up any incremental commits withgit add -p, but you can usegit commit --no-verifyto bypass the hooks if you need to.Posted on March 10, 2010 with 6 notes ()
-
vallher123 liked this
-
sixpackabsx liked this
-
sohbetkar liked this
-
alandipert reblogged this from golang and added:
enforced gofmt… ah yes, Python :)
-
golang posted this
-