Added renamer exercise
This commit is contained in:
parent
2577b92b2f
commit
9e45c522c8
|
@ -0,0 +1,3 @@
|
|||
module renamer
|
||||
|
||||
go 1.22.0
|
|
@ -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)
|
||||
|
||||
}
|
Loading…
Reference in New Issue