Move

The os.Rename function makes it possible to change a file name and/or its directory. Note that this operation replaces the destination file if it already exists.

The code for changing a file's name or its directory is as follows:

import "os"

func main() {
if err := os.Rename("file.txt", "../file.txt"); err != nil {
fmt.Println("Error:", err)
}
}
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.143.4.181