go

                   simple, fast, safe, concurrent, fun
  1. Code
  2. Search
  3. Subscribe
  4. Archive
  5. Random

explorations into google's new language by nick quaranto

Newer
Older
  • 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:

    #!/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
    end
    Make sure you run chmod a+x on that hook too. Also, this will mess up any incremental commits with git add -p, but you can use git commit --no-verify to bypass the hooks if you need to.

    Posted on March 10, 2010 with 6 notes ()

    1. vallher123 liked this
    2. sixpackabsx liked this
    3. sohbetkar liked this
    4. alandipert reblogged this from golang and added:
      enforced gofmt… ah yes, Python :)
    5. golang posted this

Field Notes Theme. Designed by Manasto Jones. Powered by Tumblr.