mirror of
https://github.com/Macrame-App/Macrame
synced 2025-12-29 15:29:26 +00:00
Alpha version be update
This commit is contained in:
parent
f5f6f25a4a
commit
e1b13b3930
12 changed files with 86 additions and 42 deletions
|
|
@ -7,9 +7,7 @@ import (
|
|||
"crypto/rand"
|
||||
"encoding/base64"
|
||||
"errors"
|
||||
"math"
|
||||
mathRand "math/rand"
|
||||
"strconv"
|
||||
"strings"
|
||||
)
|
||||
|
||||
|
|
@ -75,10 +73,11 @@ func GenerateRandomString(length int) string {
|
|||
}
|
||||
|
||||
func GenerateRandomIntegerString(length int) string {
|
||||
min := int64(0)
|
||||
max := int64(math.Pow10(length))
|
||||
randInt := min + mathRand.Int63()%(max-min+1)
|
||||
return strconv.FormatInt(randInt, 10)
|
||||
var sb strings.Builder
|
||||
for i := 0; i < length; i++ {
|
||||
sb.WriteByte('0' + byte(mathRand.Intn(10)))
|
||||
}
|
||||
return sb.String()
|
||||
}
|
||||
|
||||
func GenerateKey() string {
|
||||
|
|
|
|||
|
|
@ -13,8 +13,8 @@ var configPath = "../public/config.js"
|
|||
|
||||
func EnvGet(key string) string {
|
||||
if !configFileExists() {
|
||||
createConfigFile(configPath)
|
||||
checkFeDevDir()
|
||||
CreateConfigFile(configPath)
|
||||
CheckFeDevDir()
|
||||
}
|
||||
|
||||
data, err := os.ReadFile(configPath)
|
||||
|
|
@ -41,7 +41,8 @@ func configFileExists() bool {
|
|||
return err == nil
|
||||
}
|
||||
|
||||
func checkFeDevDir() {
|
||||
func CheckFeDevDir() {
|
||||
log.Println("Checking FE dev directory...")
|
||||
_, err := os.Stat("../fe")
|
||||
|
||||
if err != nil {
|
||||
|
|
@ -64,7 +65,7 @@ func copyConfigToFe() {
|
|||
}
|
||||
}
|
||||
|
||||
func createConfigFile(filename string) {
|
||||
func CreateConfigFile(filename string) {
|
||||
port, _ := findOpenPort()
|
||||
saltKey := GenerateKey()
|
||||
salt := saltKey[:28]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue