Skip to content

Commit

Permalink
optimize readme
Browse files Browse the repository at this point in the history
  • Loading branch information
quixote-liu committed May 11, 2022
1 parent 79ac0d0 commit f3a20bd
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,14 @@

基本使用示例
```go
package main

import (
"github.com/quixote-liu/config"
)

func main() {
var CONF = config.CONF
var CONF = config.CONF()

if err := CONF.LoadConfiguration(yourFilePath); err != nil {
panic(err)
Expand All @@ -21,6 +27,12 @@ func main() {

设置默认值示例,默认值的优先级比从配置文件里面读取的配置信息低。
```go
package conf

import (
"github.com/quixote-liu/config"
)

func init() {
RegisterServer()
}
Expand All @@ -31,6 +43,6 @@ func RegisterServer() {

group.SetString("host", "127.0.0.1")
group.SetString("port", "8080")
config.CONF.Register(group)
config.CONF().Register(group)
}
```

0 comments on commit f3a20bd

Please sign in to comment.