From 7c1a1c4f23d38929fe9a124fbe83834ae61cc796 Mon Sep 17 00:00:00 2001 From: Henrique Dias Date: Sat, 5 Mar 2016 15:46:21 +0000 Subject: [PATCH] change rename to copy --- hugo/hugo.go | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/hugo/hugo.go b/hugo/hugo.go index 6c510b3a..a8592253 100644 --- a/hugo/hugo.go +++ b/hugo/hugo.go @@ -103,13 +103,31 @@ func GetPath() string { return nil }) - err = os.Rename(exetorename, hugo) + // Copy the file + fmt.Print("Moving Hugo executable... ") + r, err := os.Open(exetorename) + if err != nil { + panic(err) + } + defer r.Close() + + w, err := os.Create(hugo) + if err != nil { + panic(err) + } + defer w.Close() + + _, err = io.Copy(w, r) + if err != nil { + panic(err) + } if err != nil { fmt.Println(err) os.Exit(-1) } + fmt.Println("done.") fmt.Println("Hugo installed at " + hugo) defer os.RemoveAll(temp) return hugo