Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

data race happens randomly #88

Open
shenqianjin opened this issue Nov 30, 2023 · 0 comments
Open

data race happens randomly #88

shenqianjin opened this issue Nov 30, 2023 · 0 comments
Assignees

Comments

@shenqianjin
Copy link

shenqianjin commented Nov 30, 2023

Reproducible Example

import (
	"fmt"
	"time"

	"github.com/jinzhu/configor"
)

var Config = struct {
	APPName string `default:"app name"`

	DB struct {
		Name     string
		User     string `default:"root"`
		Password string `required:"true" env:"DBPassword"`
		Port     uint   `default:"3306"`
	}

	Contacts []struct {
		Name  string
		Email string `required:"true"`
	}
}{}

func main() {
	configor.New(&configor.Config{AutoReload: true, AutoReloadInterval: 100 * time.Millisecond}).Load(&Config, "config.yml")
	go func() {
		for {
			time.Sleep(50 * time.Millisecond)
			fmt.Printf("config.DB: %v\n", &Config.DB)
		}
	}()
	time.Sleep(5 * time.Second)
}

Description

image
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants