Fix section "Beego configuration design" in section 13.4.md
This commit is contained in:
@@ -116,9 +116,9 @@ You can see that each of these levels has a specific purpose. For instance if we
|
||||
|
||||
## Beego configuration design
|
||||
|
||||
Configuration information parsing, beego implements a key = value configuration file read, similar ini configuration file format is a file parsing process, and then parse the data saved to the map, the last time the call through several string, int sort of function call returns the corresponding value, see the following specific implementation:
|
||||
For processing configuration information, Beego implements a key=value file parser which reads information formatted similarly to `ini` configuration files. The parser reads the configuration data and saves it to a map. Finally, it calls several functions for retrieving the value's datatype (int, string, etc). The detailed implementation can be seen below:
|
||||
|
||||
First define some ini configuration file some global constants:
|
||||
Define some global constants for the `ini` configuration file:
|
||||
|
||||
var (
|
||||
bComment = []byte{'#'}
|
||||
@@ -139,7 +139,7 @@ Defines the format of the configuration file:
|
||||
}
|
||||
|
||||
|
||||
Defines a function parses the file, parses the file of the process is to open the file, and then read line by line, parse comments, blank lines, and key = value data:
|
||||
Defines a function for parsing the file. The process begins by opening the file, then reading it line by line and parsing comments, blank lines and key=value data:
|
||||
|
||||
// ParseFile creates a new Config and parses the file configuration from the
|
||||
// named file.
|
||||
@@ -200,7 +200,7 @@ Defines a function parses the file, parses the file of the process is to open th
|
||||
return cfg, nil
|
||||
}
|
||||
|
||||
Below reads the configuration file to achieve a number of functions, the return value is determined as bool, int, float64 or string:
|
||||
Below are a number of functions the parser uses for reading the configuration file. The return value is determined as either a bool, int, float64 or string:
|
||||
|
||||
// Bool returns the boolean value for a given key.
|
||||
func (c *Config) Bool(key string) (bool, error) {
|
||||
|
||||
Reference in New Issue
Block a user