Skip to content

stevenQiang/sweetYaml

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 

Repository files navigation

sweetYaml

read yaml file use env data or default value

Introduction

I use yaml encountered some problems

  • I want use env data
  • I want use default value

Solve

I checked a lot of information, and can solve two problems

  • in yaml file you can use ${DATABASE_HOST} can incoming.
 DATABASE_HOST=localhost run main.go
  • default value in main.go
  var defaultBaseDBConfig = DBConfig {
    Host: "loclhost", 
    Port: "5432", 
    Username: "postgres", 
    Password: "postgres",
    Database: "postgres",
  }
  • in this demo, i use two layers yaml

Note

  • This is a demo, if you have questions, you can contact me.
  • If you use my code, i hope you can give me a start

About

read yaml file use env data or default value

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages