An open API service providing package, version and dependency metadata of many open source software ecosystems and registries.

Top 9.8% on proxy.golang.org
Top 3.5% dependent repos on proxy.golang.org

proxy.golang.org : github.com/graniticio/inifile

Package inifile provides a Go struct that can parse an INI-style file and make the configuration in that file available via a series of type-safe data accessors. Parsing and data-access behaviour can be configured to support most INI file variants. To parse an INI file and obtain an instance of IniConfig to access your configuration, call one of: For example: The key/value items in an INI file are referred to as properties. Each property is part of a section (properties in an INI file defined before any [section] delimiters are considered to be part of the 'global' section). Values are stored as strings. You can retrieve the value associated with a property by using one of: These methods will return an error if the requested section or name does not exist or if the value associated with the requested property could not be converted to the request data type. To check that a section of property exists before you call one of these functions use: Methods exist to return the zero value for a type instead of an error if the section/property didn't exist or if there was a problem converting the value to the requested type: Use the constant inifile.GLOBAL_SECTION as the sectionName when calling any of the above functions to work with properties that are not attached to a named section If your code needs multiple property values from the same section: it is recommended that you use an IniSection object, which offers the same functions as IniConfig but is bound to a single section: Properties can be added to an IniConfig at runtime by calling: As INI files are not governed by an agreed standard, there are a number of variations in the structure and features found in real-world INI files. To accommodate these variations, you can modify the IniOptions used when creating an IniConfig object. The recommended practice is to use the DefaultIniOptions() function to create a baseline set of options and then only modify those you need to change (see the documentation for DefaultIniOptions below to see what the default values are). For example: will parse a file using # instead of ; to identify comment lines. By default look-ups of sections and properties are case sensitive - Value("mysection", "myproperty") would not match a property called myProperty in a section called [MYPROPERTY]. This is not the behaviour of many Windows implementations of INI file libraries, so you might find files that mix and match cases. To support this behaviour set: in your IniOptions. Most INI files use the semi-colon symbol at the start of a line to indicate that the line is a comment. There are notable exceptions, including MySQL INI files, that use a different character, often #. To support this set: in your IniOptions. For readability, some INI files align property names and values like: By default the whitespace either side of the property name and value is discarded and not considered part of the property name or value. This behaviour can be disabled by setting: in your IniOptions. For readability, most INI files use blank lines to break up sections and properties. To disallow this and return an error if blank lines are encountered set: in your IniOptions. Some INI files have properties defined before the first [Section]. These properties are considered to be in the 'global' section and by default this behaviour is supported. To forbid properties in the global section, set: in your IniOptions. Use the inifile.GLOBAL_SECTION constant as the section name to access properties in the global section. Some INI files allow a property to be defined without a value like This can be problematic if, when set, that property is expected to hold a value of a specific data-type (a float in example above). Calling ValueAsFloat64 on the above would return an error. By default, IniConfig ignores any unset properties, so in the above example calling would return false To reverse this behaviour and have any unset properties stored with "" as their value, set: in your IniOptions. Go's strconv.ParseBool is extremely permissive about the values it considers to represent true or false (see https://golang.org/pkg/strconv/#ParseBool) and by default calling Will use those rules when trying to interpret a string value as a bool. Many applications require bool representations to be more precise or use counter-intuitive values for true/false. This behaviour can supported by setting in your IniOptions and then providing values for e.g: To support case-insensitve matching of the values in StrictBoolTrue and StrictBoolFalse set: By default, an INI file will not parse correctly if a line is encountered in the file that cannot be interpreted as a section, comment, property or a blank line. To ignore unparseable lines, set: in your IniOptions. Some INI files allow a comment on the same line as a property or section: By default this behaviour is not supported and the value of [database].host will be "host ;Default to localhost". To allow inline comments set: When inline comments are allowed, you must escape any instances of the comment start character in your section names, property names and property values. The default escape prefix is \ but you can change this by setting: to whatever character you want. For example, with CommentStart = ";" and CommentEscapePrefix="\" your INI file might contain The value returned by Value("messages", "message") would be "Service is too busy;load is high" Some INI files surround their values with quotes like: By default these enclosing quotes are preserved and are included when you retrieve the property's value. To change this behaviour, set: in your IniOptions. The runes (characters) that will be recognised as enclosing quotes are defined in and default to the single (') and double (") quote symbols.

Registry - Source - Documentation - JSON - codemeta.json
purl: pkg:golang/github.com/graniticio/inifile
License: Apache-2.0
Latest release: over 4 years ago
First release: over 4 years ago
Namespace: github.com/graniticio
Dependent repositories: 2
Stars: 5 on GitHub
Forks: 1 on GitHub
See more repository details: repos.ecosyste.ms
Last synced: 15 days ago

    Loading...
    Readme
    Loading...