github.com/paketo-buildpacks/packit@v1.3.2-0.20211206231111-86b75c657449/fs/move.go (about) 1 package fs 2 3 import ( 4 "fmt" 5 "os" 6 ) 7 8 // Move will move a source file or directory to a destination. For directories, 9 // move will remap relative symlinks ensuring that they align with the 10 // destination directory. If the destination exists prior to invocation, it 11 // will be removed. Additionally, the source will be removed once it has been 12 // copied to the destination. 13 func Move(source, destination string) error { 14 err := Copy(source, destination) 15 if err != nil { 16 return fmt.Errorf("failed to move: %s", err) 17 } 18 19 err = os.RemoveAll(source) 20 if err != nil { 21 return err 22 } 23 24 return nil 25 }