File tree Expand file tree Collapse file tree 1 file changed +9
-4
lines changed Expand file tree Collapse file tree 1 file changed +9
-4
lines changed Original file line number Diff line number Diff line change @@ -816,14 +816,16 @@ type UnifiedDiff struct {
816
816
// 'fromfile', 'tofile', 'fromfiledate', and 'tofiledate'.
817
817
// The modification times are normally expressed in the ISO 8601 format.
818
818
func WriteUnifiedDiff (writer io.Writer , diff UnifiedDiff ) error {
819
- buf := bufio .NewWriter (writer )
820
- defer buf .Flush ()
819
+ //buf := bufio.NewWriter(writer)
820
+ //defer buf.Flush()
821
+ var bld strings.Builder
822
+ bld .Reset ()
821
823
wf := func (format string , args ... interface {}) error {
822
- _ , err := buf . WriteString ( fmt .Sprintf ( format , args ... ) )
824
+ _ , err := fmt .Fprintf ( & bld , format , args ... )
823
825
return err
824
826
}
825
827
ws := func (s string ) error {
826
- _ , err := buf .WriteString (s )
828
+ _ , err := bld .WriteString (s )
827
829
return err
828
830
}
829
831
@@ -887,6 +889,9 @@ func WriteUnifiedDiff(writer io.Writer, diff UnifiedDiff) error {
887
889
}
888
890
}
889
891
}
892
+ buf := bufio .NewWriter (writer )
893
+ buf .WriteString (bld .String ())
894
+ buf .Flush ()
890
895
return nil
891
896
}
892
897
You can’t perform that action at this time.
0 commit comments