remove the need to setup .env and ask for porkbun credential name directly

This commit is contained in:
juancwu 2026-01-21 19:18:47 +00:00
commit ec94e6ad46
7 changed files with 164 additions and 47 deletions

View file

@ -1,33 +0,0 @@
package config
import (
"fmt"
"os"
"github.com/joho/godotenv"
)
type Config struct {
PorkbunApiKeyName string
PorkbunSecretApiKeyName string
}
func Load() *Config {
godotenv.Load()
cfg := &Config{
PorkbunApiKeyName: envRequired("PORKBUN_API_KEY_NAME"),
PorkbunSecretApiKeyName: envRequired("PORKBUN_SECRET_API_KEY_NAME"),
}
return cfg
}
func envRequired(key string) string {
value, ok := os.LookupEnv(key)
if !ok || value == "" {
fmt.Printf("Error: required environment variable %s not set.\n", key)
os.Exit(1)
}
return value
}