From 9e45c522c88408174d18ac3bfbe7f06f81bcf606 Mon Sep 17 00:00:00 2001 From: raul Date: Wed, 28 Feb 2024 06:45:40 +0100 Subject: [PATCH] Added renamer exercise --- golangr/renamer/go.mod | 3 +++ golangr/renamer/main.go | 21 +++++++++++++++++++++ 2 files changed, 24 insertions(+) create mode 100644 golangr/renamer/go.mod create mode 100644 golangr/renamer/main.go diff --git a/golangr/renamer/go.mod b/golangr/renamer/go.mod new file mode 100644 index 0000000..b1c7d3b --- /dev/null +++ b/golangr/renamer/go.mod @@ -0,0 +1,3 @@ +module renamer + +go 1.22.0 diff --git a/golangr/renamer/main.go b/golangr/renamer/main.go new file mode 100644 index 0000000..e40379f --- /dev/null +++ b/golangr/renamer/main.go @@ -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) + +}