github.com/Benchkram/bob@v0.0.0-20220321080157-7c8f3876e225/pkg/file/file.go (about) 1 package file 2 3 import ( 4 "io/ioutil" 5 "os" 6 ) 7 8 // Exists return true when a file exists, false otherwise. 9 func Exists(path string) bool { 10 _, err := os.Stat(path) 11 return !os.IsNotExist(err) 12 } 13 14 // Copy file to destination 15 // TODO: Use io.Copy instead of completely reading, then writing the file to use Go optimizations. 16 func Copy(dst, src string) error { 17 input, err := ioutil.ReadFile(src) 18 if err != nil { 19 return err 20 } 21 22 err = ioutil.WriteFile(dst, input, 0644) 23 if err != nil { 24 return err 25 } 26 27 return nil 28 }