Skip to content

Commit

Permalink
[v0.5.0] update
Browse files Browse the repository at this point in the history
  • Loading branch information
evald24 committed Aug 7, 2022
1 parent 4877a2b commit b6a6687
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 21 deletions.
13 changes: 7 additions & 6 deletions README.MD
Original file line number Diff line number Diff line change
Expand Up @@ -148,15 +148,15 @@ const (
)

// GetConfig - get the configuration
func GetConfig() Config {
return *cfg
func GetConfig() *Config {
return cfg
}

var fileConfig string
var cfg *Config

// Init - initializing the configuration
func Init(configPath string) error {
func Init(configPath string) (*Config, error) {
...
}

Expand Down Expand Up @@ -184,14 +184,15 @@ import (
)

func main() {
if err := config.Init("example/config.yaml"); err != nil {
cfg, err := config.Init("example/config.yaml");
if err != nil {
log.Fatal(err)
}

go hotReloadConfig()

fmt.Printf("config: %+v\n", config.GetConfig())
fmt.Printf("project name: %s", config.GetConfig().Project.Name)
fmt.Printf("config: %+v\n", cfg)
fmt.Printf("project name: %s", cfg.Project.Name)
}

// Example of a hot reload configuration
Expand Down
12 changes: 6 additions & 6 deletions example/config/config.gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 4 additions & 3 deletions example/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,15 @@ import (
)

func main() {
if err := config.Init("example/config.yaml"); err != nil {
cfg, err := config.Init("example/config.yaml")
if err != nil {
log.Fatal(err)
}

go hotReloadConfig()

fmt.Printf("config: %+v\n", config.GetConfig())
fmt.Printf("project name: %s", config.GetConfig().Project.Name)
fmt.Printf("config: %+v\n", cfg)
fmt.Printf("project name: %s", cfg.Project.Name)
}

// Example of a hot reload configuration
Expand Down
12 changes: 6 additions & 6 deletions internal/generator/template.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit b6a6687

Please sign in to comment.