1
0
mirror of https://github.com/go-micro/go-micro.git synced 2025-12-23 22:01:02 +02:00
Files
Eng Zer Jun bc40df0c9e Update github.com/imdario/mergo to dario.cat/mergo (#2810)
Mergo v1 is released with a new module path URL. No breaking changes,
only the module path update and bug fixes.

Reference: https://github.com/darccio/mergo/releases/tag/v1.0.0
Reference: https://github.com/darccio/mergo/releases/tag/v1.0.1
Reference: https://github.com/darccio/mergo/releases/tag/v1.0.2

Signed-off-by: Eng Zer Jun <engzerjun@gmail.com>
2025-10-14 11:18:28 +01:00
..
v5
2024-06-04 21:40:43 +01:00
2022-09-30 20:32:55 +02:00

Flag Source

The flag source reads config from flags

Format

We expect the use of the flag package. Upper case flags will be lower cased. Dashes will be used as delimiters.

Example

dbAddress := flag.String("database_address", "127.0.0.1", "the db address")
dbPort := flag.Int("database_port", 3306, "the db port)

Becomes

{
  "database": {
    "address": "127.0.0.1",
    "port": 3306
  }
}

New Source

flagSource := flag.NewSource(
	// optionally enable reading of unset flags and their default
	// values into config, defaults to false
	IncludeUnset(true)
)

Load Source

Load the source into config

// Create new config
conf := config.NewConfig()

// Load flag source
conf.Load(flagSource)