first commit
This commit is contained in:
@@ -0,0 +1,72 @@
|
||||
package utils
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
)
|
||||
|
||||
func BytesToStrings(bytes []byte) []string {
|
||||
var strings []string
|
||||
for _, b := range bytes {
|
||||
strings = append(strings, string(b))
|
||||
}
|
||||
return strings
|
||||
}
|
||||
|
||||
func GetGitToken() string {
|
||||
token := os.Getenv("GIT_TOKEN")
|
||||
return token
|
||||
}
|
||||
|
||||
func IsValidToken(token string) bool {
|
||||
if len(token) != 40 {
|
||||
return false
|
||||
}
|
||||
|
||||
// Check if token contains only hexadecimal characters (0-9 and a-f)
|
||||
for _, c := range token {
|
||||
if !(('0' <= c && c <= '9') || ('a' <= c && c <= 'f')) {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
func IsValidOrg(org string) bool {
|
||||
// Check if organization is valid
|
||||
// ...
|
||||
return true
|
||||
}
|
||||
|
||||
func IsValidProjectName(name string) bool {
|
||||
// Check if project name is valid
|
||||
// ...
|
||||
return true
|
||||
}
|
||||
|
||||
// function that print error message and exit program with specific error code
|
||||
func ExitWithError(code int, msg string) {
|
||||
// Print error message
|
||||
fmt.Println(msg)
|
||||
// Exit program with specific error code
|
||||
os.Exit(code)
|
||||
}
|
||||
|
||||
func CreateDir(dirName string) {
|
||||
path, err := os.Getwd()
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
fmt.Println("Current working directory: ", path)
|
||||
|
||||
dirPath := filepath.Join(path, dirName)
|
||||
|
||||
err = os.Mkdir(dirPath, 0755)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
fmt.Printf("Created directory '%s' \n", dirName)
|
||||
}
|
||||
Reference in New Issue
Block a user