lots o progress

This commit is contained in:
2023-09-11 05:08:12 -04:00
parent 323b70eb9f
commit ac98a90222
8 changed files with 322 additions and 115 deletions

53
util.go Normal file
View File

@@ -0,0 +1,53 @@
package main
import (
"code.gitea.io/sdk/gitea"
"fmt"
"git.nevets.tech/Steven/ezconf"
"github.com/google/go-github/v55/github"
"os"
)
type Domain struct {
name *string
config *ezconf.Configuration
description *string
ghClient *github.Client
gtClient *gitea.Client
}
func createFile(fileName string, data []byte) {
fileInfo, err := os.Stat(fileName)
if err != nil {
if os.IsNotExist(err) {
file, err := os.Create(fileName)
if err != nil {
fmt.Println("Error creating configuration file:", err)
os.Exit(1)
}
_, err = file.Write(data)
if err != nil {
fmt.Println("Error writing to file;", err)
os.Exit(1)
}
} else {
fmt.Println("Error opening configuration file:", err)
os.Exit(1)
}
} else {
if fileInfo.Size() == 0 {
file, err := os.Create(fileName)
if err != nil {
fmt.Println("Error creating configuration file:", err)
os.Exit(1)
}
_, err = file.Write(data)
if err != nil {
fmt.Println("Error writing to file:", err)
os.Exit(1)
}
}
}
}