Compare commits

..

1 commit
main ... backup

Author SHA1 Message Date
b8ae6e364a Starting implementation of the backup service.
Some checks failed
CI/CD / build-and-test (push) Has been cancelled
2024-12-06 18:39:47 -03:00
3 changed files with 40 additions and 0 deletions

View file

@ -0,0 +1,17 @@
package main
import (
"fmt"
"os"
"github.com/cotti/Guestbooky-backup/internal/compactor"
)
func main() {
err := compactor.Compact(os.Args[1], os.Args[2])
if err != nil {
fmt.Println("An error occurred while compacting:", err.Error())
os.Exit(1)
}
os.Exit(0)
}

View file

@ -0,0 +1,3 @@
module github.com/cotti/Guestbooky-backup
go 1.23.1

View file

@ -0,0 +1,20 @@
package compactor
import (
"errors"
"fmt"
"io/fs"
"os"
)
func Compact(source, destination string) error {
fmt.Println(
"Compacting", source, "to", destination,
)
if _, err := os.Stat(source); errors.Is(err, fs.ErrNotExist) {
return errors.New("source file does not exist")
}
return nil
}