File tree Expand file tree Collapse file tree 1 file changed +8
-18
lines changed Expand file tree Collapse file tree 1 file changed +8
-18
lines changed Original file line number Diff line number Diff line change @@ -58,33 +58,23 @@ func moveFile(src, dst string) error {
5858 return os .Remove (src )
5959}
6060
61- // copyFile copies the given file from src to dst. It copies first to a .tmp
62- // file which is then moved over a possibly already existing file at the
63- // destination.
61+ // copyFile copies the given file from src to dst. It can copy over
62+ // a possibly already existing file at the destination.
6463func copyFile (src , dst string ) error {
65- inf , err := os .Open (src )
64+ source , err := os .Open (src )
6665 if err != nil {
6766 return err
6867 }
69- defer inf .Close ()
70- outpath := dst + ".tmp"
71- outf , err := os .Create (outpath )
72- if err != nil {
73- return err
74- }
75-
76- _ , err = io .Copy (outf , inf )
77- if err != nil {
78- os .Remove (outpath )
79- return err
80- }
68+ defer source .Close ()
8169
82- err = outf . Close ( )
70+ destination , err := os . Create ( dst )
8371 if err != nil {
8472 return err
8573 }
74+ defer destination .Close ()
8675
87- return os .Rename (dst + ".tmp" , dst )
76+ _ , err = io .Copy (destination , source )
77+ return err
8878}
8979
9080// Build compiles and links the given package and writes it to outpath.
You can’t perform that action at this time.
0 commit comments