mirror of
https://github.com/httprunner/httprunner.git
synced 2026-05-07 08:12:41 +08:00
fix: load env once
This commit is contained in:
@@ -30,12 +30,12 @@ type Config struct {
|
||||
}
|
||||
|
||||
var (
|
||||
globalConfig *Config
|
||||
once sync.Once
|
||||
globalConfig *Config
|
||||
getConfigOnce sync.Once
|
||||
)
|
||||
|
||||
func GetConfig() *Config {
|
||||
once.Do(func() {
|
||||
getConfigOnce.Do(func() {
|
||||
cfg := &Config{
|
||||
StartTime: time.Now(),
|
||||
}
|
||||
|
||||
@@ -5,15 +5,18 @@ import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strconv"
|
||||
"sync"
|
||||
|
||||
"github.com/joho/godotenv"
|
||||
"github.com/rs/zerolog/log"
|
||||
)
|
||||
|
||||
var loadEnvOnce sync.Once
|
||||
|
||||
// LoadEnv loads environment variables from .env file
|
||||
// it will search for .env file from current working directory upward recursively
|
||||
func LoadEnv() (err error) {
|
||||
once.Do(func() {
|
||||
loadEnvOnce.Do(func() {
|
||||
// get current working directory
|
||||
var cwd string
|
||||
cwd, err = os.Getwd()
|
||||
|
||||
@@ -1 +1 @@
|
||||
v5.0.0-beta-2504212133
|
||||
v5.0.0-beta-2504212250
|
||||
|
||||
Reference in New Issue
Block a user