Rename a file in Golang
Example
package main
import (
"log"
"os"
)
func main() {
oldName := "test.txt"
newName := "testing.txt"
err := os.Rename(oldName, newName)
if err != nil {
log.Fatal(err)
}
}
Most Helpful This Week
Golang Create Copy of a file at another location
Go program to compress list of files into Zip file
Go program to read a text file character by character
Golang program to delete a specific file
Go program to add or append content at the end of text file
Go program to read list of files inside Zip file