Top 7.0% forks on proxy.golang.org
proxy.golang.org : github.com/xrash/gonf
Package _gonf_ provides an interface to a simple configuration file format. Below is a simple example to introduce you to the format. As intuitively noted, the format supports tables (maps), arrays and string literals. This should be all you need. Now, a simple example of code (given the above file): You can also directly map your config to a struct. Example: > NOTE: The struct fields have to be exported so the Map function can see them through reflection One nice feature is the automatic merge of multiple equal keys into an array. Consider the following example: This will be translated in a semantic analyzing phase to: And can therefore be accessed like this: A problem that arises in practice is the need to traverse through non-scalar types. In gonf, we got tables and arrays, and both can be traversed. The order of elements in a table may not be guaranteed by the implementation, but the order in an array is expected to be guaranteed in any implementation. There are two ways to traverse through these types: ### Using traversing functions ### Using the underlying implemented data structure If you need to check which type the Config object holds, you can use the functions: You are encouraged to see the working examples of tests/gonf_test.go. Here is the LL(1) grammar: [the golang string specification](http://golang.org/ref/spec#String_literals)
Registry
-
Source
- Documentation
- JSON
purl: pkg:golang/github.com/xrash/gonf
License: BSD-3-Clause
Latest release: over 4 years ago
First release: over 4 years ago
Namespace: github.com/xrash
Stars: 8 on GitHub
Forks: 1 on GitHub
See more repository details: repos.ecosyste.ms
Last synced: 19 days ago