Added renamer exercise

This commit is contained in:
raul 2024-02-28 06:45:40 +01:00
parent 2577b92b2f
commit 9e45c522c8
2 changed files with 24 additions and 0 deletions

3
golangr/renamer/go.mod Normal file
View File

@ -0,0 +1,3 @@
module renamer
go 1.22.0

21
golangr/renamer/main.go Normal file
View File

@ -0,0 +1,21 @@
package main
import (
"fmt"
"os"
)
var src string
var dst string
func main() {
if len(os.Args) != 3 {
fmt.Println("Usage: ./renamer oldfile newfile")
os.Exit(1)
}
src = os.Args[1]
dst = os.Args[2]
os.Rename(src, dst)
}