@hgcommand
def gofmt(ui, repo, *pats, **opts):
 if codereview_disabled:
  raise hg_util.Abort(codereview_disabled)
 files = ChangedExistingFiles(ui, repo, pats, opts)
 files = gofmt_required(files)
 if (not files):
  ui.status('no modified go files\n')
  return
 cwd = os.getcwd()
 files = [RelativePath(((repo.root + '/') + f), cwd) for f in files]
 try:
  cmd = ['gofmt', '-l']
  if (not opts['list']):
   cmd += ['-w']
  if (subprocess.call((cmd + files)) != 0):
   raise hg_util.Abort('gofmt did not exit cleanly')
 except hg_error.Abort as e:
  raise
 except:
  raise hg_util.Abort(('gofmt: ' + ExceptionDetail()))
 return

@ hgcommand def gofmt ( ui , repo , * pats , ** opts ) : if codereview_disabled : raise hg_util . Abort ( codereview_disabled ) files = ChangedExistingFiles ( ui , repo , pats , opts ) files = gofmt_required ( files ) if ( not files ) : ui . status ( 'no modified go files\n' ) return cwd = os . getcwd ( ) files = [ RelativePath ( ( ( repo . root + '/' ) + f ) , cwd ) for f in files ] try : cmd = [ 'gofmt' , '-l' ] if ( not opts [ 'list' ] ) : cmd += [ '-w' ] if ( subprocess . call ( ( cmd + files ) ) != 0 ) : raise hg_util . Abort ( 'gofmt did not exit cleanly' ) except hg_error . Abort as e : raise except : raise hg_util . Abort ( ( 'gofmt: ' + ExceptionDetail ( ) ) ) return
apply gofmt to modified files applies gofmt to the modified files in the repository that match the given patterns .