24 lines
436 B
Go
24 lines
436 B
Go
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)
|
|
}
|
|
}
|