lots o progress
This commit is contained in:
53
util.go
Normal file
53
util.go
Normal 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)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user