code: func (c *hookCmd) hookGofmt() error {
  	if os.Getenv("GIT_GOFMT_HOOK") == "off" {
  		printf("gofmt disabled by $GIT_GOFMT_HOOK=off\n")
  		return nil
  	}
  
  	files, err := c.runGofmt()
  	if err != nil {
  		printf("gofmt hook reported errors:\n\t%v\n", strings.Replace(strings.TrimSpace(err.Error()), "\n", "\n\t", -1))
  		return errors.New("gofmt errors")
  	}
  	if len(files) == 0 {
  		return nil
  	}
  	printf("You need to format with gofmt:\n\tgofmt -w %s\n",
  		strings.Join(files, " "))
  	return errors.New("gofmt required")
  }
docs: // hookGofmt runs a gofmt check on the local files matching the files in the
  // git staging area.
  // An error is returned if something went wrong or if some of the files need
  // gofmting. In the latter case, the instruction is printed.