Skip to content

Commit 65f16c1

Browse files
committed
docs: fix indentation in code samples
Signed-off-by: Mark Sagi-Kazar <[email protected]>
1 parent 0d7e803 commit 65f16c1

File tree

1 file changed

+40
-40
lines changed

1 file changed

+40
-40
lines changed

README.md

+40-40
Original file line numberDiff line numberDiff line change
@@ -127,11 +127,11 @@ You can handle the specific case where no config file is found like this:
127127

128128
```go
129129
if err := viper.ReadInConfig(); err != nil {
130-
if _, ok := err.(viper.ConfigFileNotFoundError); ok {
131-
// Config file not found; ignore error if desired
132-
} else {
133-
// Config file was found but another error was produced
134-
}
130+
if _, ok := err.(viper.ConfigFileNotFoundError); ok {
131+
// Config file not found; ignore error if desired
132+
} else {
133+
// Config file was found but another error was produced
134+
}
135135
}
136136

137137
// Config file found and successfully parsed
@@ -354,7 +354,7 @@ func main() {
354354

355355
i := viper.GetInt("flagname") // retrieve value from viper
356356

357-
...
357+
// ...
358358
}
359359
```
360360

@@ -503,18 +503,18 @@ runtime_viper.Unmarshal(&runtime_conf)
503503
// open a goroutine to watch remote changes forever
504504
go func(){
505505
for {
506-
time.Sleep(time.Second * 5) // delay after each request
507-
508-
// currently, only tested with etcd support
509-
err := runtime_viper.WatchRemoteConfig()
510-
if err != nil {
511-
log.Errorf("unable to read remote config: %v", err)
512-
continue
513-
}
514-
515-
// unmarshal new config into our runtime config struct. you can also use channel
516-
// to implement a signal to notify the system of the changes
517-
runtime_viper.Unmarshal(&runtime_conf)
506+
time.Sleep(time.Second * 5) // delay after each request
507+
508+
// currently, only tested with etcd support
509+
err := runtime_viper.WatchRemoteConfig()
510+
if err != nil {
511+
log.Errorf("unable to read remote config: %v", err)
512+
continue
513+
}
514+
515+
// unmarshal new config into our runtime config struct. you can also use channel
516+
// to implement a signal to notify the system of the changes
517+
runtime_viper.Unmarshal(&runtime_conf)
518518
}
519519
}()
520520
```
@@ -546,7 +546,7 @@ Example:
546546
```go
547547
viper.GetString("logfile") // case-insensitive Setting & Getting
548548
if viper.GetBool("verbose") {
549-
fmt.Println("verbose enabled")
549+
fmt.Println("verbose enabled")
550550
}
551551
```
552552
### Accessing nested keys
@@ -669,7 +669,7 @@ So instead of doing that let's pass a Viper instance to the constructor that rep
669669
```go
670670
cache1Config := viper.Sub("cache.cache1")
671671
if cache1Config == nil { // Sub returns nil if the key cannot be found
672-
panic("cache configuration not found")
672+
panic("cache configuration not found")
673673
}
674674
675675
cache1 := NewCache(cache1Config)
@@ -681,10 +681,10 @@ Internally, the `NewCache` function can address `max-items` and `item-size` keys
681681

682682
```go
683683
func NewCache(v *Viper) *Cache {
684-
return &Cache{
685-
MaxItems: v.GetInt("max-items"),
686-
ItemSize: v.GetInt("item-size"),
687-
}
684+
return &Cache{
685+
MaxItems: v.GetInt("max-items"),
686+
ItemSize: v.GetInt("item-size"),
687+
}
688688
}
689689
```
690690

@@ -726,18 +726,18 @@ you have to change the delimiter:
726726
v := viper.NewWithOptions(viper.KeyDelimiter("::"))
727727

728728
v.SetDefault("chart::values", map[string]interface{}{
729-
"ingress": map[string]interface{}{
730-
"annotations": map[string]interface{}{
731-
"traefik.frontend.rule.type": "PathPrefix",
732-
"traefik.ingress.kubernetes.io/ssl-redirect": "true",
733-
},
734-
},
729+
"ingress": map[string]interface{}{
730+
"annotations": map[string]interface{}{
731+
"traefik.frontend.rule.type": "PathPrefix",
732+
"traefik.ingress.kubernetes.io/ssl-redirect": "true",
733+
},
734+
},
735735
})
736736

737737
type config struct {
738738
Chart struct{
739-
Values map[string]interface{}
740-
}
739+
Values map[string]interface{}
740+
}
741741
}
742742

743743
var C config
@@ -794,17 +794,17 @@ You can use your favorite format's marshaller with the config returned by `AllSe
794794

795795
```go
796796
import (
797-
yaml "gopkg.in/yaml.v2"
798-
// ...
797+
yaml "gopkg.in/yaml.v2"
798+
// ...
799799
)
800800

801801
func yamlStringSettings() string {
802-
c := viper.AllSettings()
803-
bs, err := yaml.Marshal(c)
804-
if err != nil {
805-
log.Fatalf("unable to marshal config to YAML: %v", err)
806-
}
807-
return string(bs)
802+
c := viper.AllSettings()
803+
bs, err := yaml.Marshal(c)
804+
if err != nil {
805+
log.Fatalf("unable to marshal config to YAML: %v", err)
806+
}
807+
return string(bs)
808808
}
809809
```
810810

0 commit comments

Comments
 (0)