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