Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(840)

Delta Between Two Patch Sets: src/cmd/fix/main.go

Issue 6852075: code review 6852075: go/format: Package format implements standard formattin... (Closed)
Left Patch Set: diff -r 8f9a26de2b20 https://code.google.com/p/go Created 11 years, 4 months ago
Right Patch Set: diff -r 7646c94159a1 https://code.google.com/p/go Created 11 years, 4 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « no previous file | src/cmd/godoc/godoc.go » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
1 // Copyright 2011 The Go Authors. All rights reserved. 1 // Copyright 2011 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style 2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file. 3 // license that can be found in the LICENSE file.
4 4
5 package main 5 package main
6 6
7 import ( 7 import (
8 "bytes" 8 "bytes"
9 "flag" 9 "flag"
10 "fmt" 10 "fmt"
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 } 94 }
95 } 95 }
96 96
97 os.Exit(exitCode) 97 os.Exit(exitCode)
98 } 98 }
99 99
100 const parserMode = parser.ParseComments 100 const parserMode = parser.ParseComments
101 101
102 func gofmtFile(f *ast.File) ([]byte, error) { 102 func gofmtFile(f *ast.File) ([]byte, error) {
103 var buf bytes.Buffer 103 var buf bytes.Buffer
104 ast.SortImports(fset, f)
105 if err := format.Node(&buf, fset, f); err != nil { 104 if err := format.Node(&buf, fset, f); err != nil {
106 return nil, err 105 return nil, err
107 } 106 }
108 return buf.Bytes(), nil 107 return buf.Bytes(), nil
109 } 108 }
110 109
111 func processFile(filename string, useStdin bool) error { 110 func processFile(filename string, useStdin bool) error {
112 var f *os.File 111 var f *os.File
113 var err error 112 var err error
114 var fixlog bytes.Buffer 113 var fixlog bytes.Buffer
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
250 f2.Write(b2) 249 f2.Write(b2)
251 250
252 data, err = exec.Command("diff", "-u", f1.Name(), f2.Name()).CombinedOut put() 251 data, err = exec.Command("diff", "-u", f1.Name(), f2.Name()).CombinedOut put()
253 if len(data) > 0 { 252 if len(data) > 0 {
254 // diff exits with a non-zero status when the files don't match. 253 // diff exits with a non-zero status when the files don't match.
255 // Ignore that failure as long as we get output. 254 // Ignore that failure as long as we get output.
256 err = nil 255 err = nil
257 } 256 }
258 return 257 return
259 } 258 }
LEFTRIGHT

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b