roese-utils/rsconfig/rsconfig.go

24 lines
436 B
Go
Raw Permalink Normal View History

2023-10-08 12:41:50 +02:00
package rsconfig
import (
"fmt"
"os"
)
func CreateEnvConfigFileIfNotExists(content string) {
if os.Getenv("DOCKER") != "" {
return
}
if _, err := os.Stat(".env"); os.IsNotExist(err) {
err := os.WriteFile(".env", []byte(content), 0644)
if err != nil {
panic("Failed to create .env file, err: " + err.Error())
}
fmt.Println("Config .env was created. Please configure and start the server again.")
os.Exit(1)
}
}