1
0
mirror of https://github.com/go-kratos/kratos.git synced 2025-02-05 13:15:11 +02:00
Casper-Mars c1e98e41de
fix(config/consul):Config from consul skip empty key (#1830)
* feat(config/consul):skip empty key

* feat(config/consul):delete empty blank
2022-02-21 18:16:56 +08:00
..
2022-01-28 14:56:32 +08:00

Consul Config

import (
    "github.com/go-kratos/kratos/contrib/config/consul/v2"
    "github.com/hashicorp/consul/api"
)
func main() {

    consulClient, err := api.NewClient(&api.Config{
    Address: "127.0.0.1:8500",
    })
    if err != nil {
        panic(err)
    }
    cs, err := consul.New(consulClient, consul.WithPath("app/cart/configs/"))
    //consul中需要标注文件后缀,kratos读取配置需要适配文件后缀
    //The file suffix needs to be marked, and kratos needs to adapt the file suffix to read the configuration.
    if err != nil {
        panic(err)
    }
    c := config.New(config.WithSource(cs))
}