Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FEATURE] it's option to set case sensitive #1541

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@
/build/
/var/
/vendor/
go.mod
go.sum
45 changes: 45 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,42 @@ if err := viper.ReadInConfig(); err != nil {

*NOTE [since 1.6]:* You can also have a file without an extension and specify the format programmaticaly. For those configuration files that lie in the home of the user without any extension like `.bashrc`

### MapTo
- source file
```yaml
service:
port: 1234
ip: "127.0.0.1"
version: 1.0.01
```
- use MapTo

```go
type Service struct {
Port int `viper:"port"`
IP string `viper:"ip"`
}
//your prepare code ...

var service Service
var version string

if err := viper.MapTo("service",&service); err != nil {
//error handler...
}
if err := viper.MapTo("version",&version); err != nil {
//error handler...
}



log.Println(service,version)

//....

```


### Writing Config Files

Reading from config files is useful, but at times you want to store all modifications made at run time.
Expand Down Expand Up @@ -862,7 +898,16 @@ application foundation needs.
Is there a better name for a [commander](http://en.wikipedia.org/wiki/Cobra_Commander)?

### Does Viper support case sensitive keys?
#### [FEATURE] surport case sensitive
```go
// if you want to keep case insensitive, you can do nothing
// but if you want to make it case sensitive, please do the following step
func main(){
viper.SetCaseSensitive()

// your code next...
}
```
**tl;dr:** No.

Viper merges configuration from various sources, many of which are either case insensitive or uses different casing than the rest of the sources (eg. env vars).
Expand Down
75 changes: 0 additions & 75 deletions go.mod

This file was deleted.

Loading