diff options
author | Lauris BH <lauris@nix.lv> | 2017-11-15 05:34:42 +0200 |
---|---|---|
committer | Lunny Xiao <xiaolunwen@gmail.com> | 2017-11-15 11:34:42 +0800 |
commit | a6f337046f0dde4cbf5df1cc83a9e0e79a4db8aa (patch) | |
tree | ff8c2373a537e415c50a2a2ad3f8a7b1b5e9e17a /vendor/gopkg.in/ini.v1/README.md | |
parent | bd23e36becde2fbf109c51ee2abcaa167880a29a (diff) | |
download | gitea-a6f337046f0dde4cbf5df1cc83a9e0e79a4db8aa.tar.gz gitea-a6f337046f0dde4cbf5df1cc83a9e0e79a4db8aa.zip |
Update go-ini dependency and remove semicolon hack in translations (#2913)
Diffstat (limited to 'vendor/gopkg.in/ini.v1/README.md')
-rw-r--r-- | vendor/gopkg.in/ini.v1/README.md | 29 |
1 files changed, 23 insertions, 6 deletions
diff --git a/vendor/gopkg.in/ini.v1/README.md b/vendor/gopkg.in/ini.v1/README.md index e67d51f320..f4ff27cd30 100644 --- a/vendor/gopkg.in/ini.v1/README.md +++ b/vendor/gopkg.in/ini.v1/README.md @@ -101,7 +101,7 @@ skip-name-resolve By default, this is considered as missing value. But if you know you're going to deal with those cases, you can assign advanced load options: ```go -cfg, err := LoadSources(LoadOptions{AllowBooleanKeys: true}, "my.cnf")) +cfg, err := ini.LoadSources(ini.LoadOptions{AllowBooleanKeys: true}, "my.cnf")) ``` The value of those keys are always `true`, and when you save to a file, it will keep in the same foramt as you read. @@ -125,7 +125,7 @@ If you want to save a value with `#` or `;`, please quote them with ``` ` ``` or Alternatively, you can use following `LoadOptions` to completely ignore inline comments: ```go -cfg, err := LoadSources(LoadOptions{IgnoreInlineComment: true}, "app.ini")) +cfg, err := ini.LoadSources(ini.LoadOptions{IgnoreInlineComment: true}, "app.ini")) ``` ### Working with sections @@ -329,6 +329,20 @@ foo = "some value" // foo: some value bar = 'some value' // bar: some value ``` +Sometimes you downloaded file from [Crowdin](https://crowdin.com/) has values like the following (value is surrounded by double quotes and quotes in the value are escaped): + +```ini +create_repo="created repository <a href=\"%s\">%s</a>" +``` + +How do you transform this to regular format automatically? + +```go +cfg, err := ini.LoadSources(ini.LoadOptions{UnescapeValueDoubleQuotes: true}, "en-US.ini")) +cfg.Section("<name of your section>").Key("create_repo").String() +// You got: created repository <a href="%s">%s</a> +``` + That's all? Hmm, no. #### Helper methods of working with values @@ -480,7 +494,7 @@ cfg.Section("package.sub").ParentKeys() // ["CLONE_URL"] Sometimes, you have sections that do not contain key-value pairs but raw content, to handle such case, you can use `LoadOptions.UnparsableSections`: ```go -cfg, err := LoadSources(LoadOptions{UnparseableSections: []string{"COMMENTS"}}, `[COMMENTS] +cfg, err := ini.LoadSources(ini.LoadOptions{UnparseableSections: []string{"COMMENTS"}}, `[COMMENTS] <1><L.Slide#2> This slide has the fuel listed in the wrong units <e.1>`)) body := cfg.Section("COMMENTS").Body() @@ -573,7 +587,7 @@ Why not? ```go type Embeded struct { - Dates []time.Time `delim:"|"` + Dates []time.Time `delim:"|" comment:"Time data"` Places []string `ini:"places,omitempty"` None []int `ini:",omitempty"` } @@ -581,10 +595,10 @@ type Embeded struct { type Author struct { Name string `ini:"NAME"` Male bool - Age int + Age int `comment:"Author's age"` GPA float64 NeverMind string `ini:"-"` - *Embeded + *Embeded `comment:"Embeded section"` } func main() { @@ -605,10 +619,13 @@ So, what do I get? ```ini NAME = Unknwon Male = true +; Author's age Age = 21 GPA = 2.8 +; Embeded section [Embeded] +; Time data Dates = 2015-08-07T22:14:22+08:00|2015-08-07T22:14:22+08:00 places = HangZhou,Boston ``` |