github.com/annwntech/go-micro/v2@v2.9.5/config/source/memory/README.md (about)

     1  # Memory Source
     2  
     3  The memory source provides in-memory data as a source
     4  
     5  ## Memory Format
     6  
     7  The expected data format is json
     8  
     9  ```json
    10  data := []byte(`{
    11      "hosts": {
    12          "database": {
    13              "address": "10.0.0.1",
    14              "port": 3306
    15          },
    16          "cache": {
    17              "address": "10.0.0.2",
    18              "port": 6379
    19          }
    20      }
    21  }`)
    22  ```
    23  
    24  ## New Source
    25  
    26  Specify source with data
    27  
    28  ```go
    29  memorySource := memory.NewSource(
    30  	memory.WithJSON(data),
    31  )
    32  ```
    33  
    34  ## Load Source
    35  
    36  Load the source into config
    37  
    38  ```go
    39  // Create new config
    40  conf := config.NewConfig()
    41  
    42  // Load memory source
    43  conf.Load(memorySource)
    44  ```