Nacos远程配置集成

创建配置对象

  1. config := configuration.NACOS("config")
  2. // 或
  3. abstractions.NewConfigurationBuilder().AddEnvironment().AddYamlFile(“config”).Build()

配置文件

  1. yoyogo:
  2. application:
  3. name: yoyogo_demo_dev
  4. metadata: "develop"
  5. server:
  6. type: "fasthttp"
  7. address: ":8080"
  8. cloud:
  9. discovery:
  10. cache:
  11. ttl: 30 # seconds
  12. strategy: "round-robin" # round-robin , weight-time , random
  13. type: "nacos"
  14. metadata:
  15. url: "127.0.0.1"
  16. port: 8080
  17. namespace: "public"
  18. group: "DEFAULT_GROUP"
  19. cluster: ""
  20. configserver:
  21. dataId: "simple_demo" # nacos的 DataId
  22. auth:
  23. enable: true
  24. username: "root"
  25. password: "1234"