Skip to content

Commit

Permalink
docs: add docs to Decode func
Browse files Browse the repository at this point in the history
  • Loading branch information
Gornak40 committed Nov 9, 2024
1 parent 9143784 commit aa4808e
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions pkg/miniparse/miniparse.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,23 @@ var (

// Decode .mini config file into value using reflect.
// The mini format is similar to ini, but very strict.
//
// Each line of the config must be one of the following: blank, comment, record title, record field.
// Leading spaces are not allowed. End-of-line spaces are only allowed in record field lines.
// A non-empty .mini config file must end with a blank string.
// A comment must begin with a '#' character. All comments will be ignored by the parser.
// The record title must be "[title]", where title is the non-empty name of the varname.
// Varnames contain only lowercase ascii letters, digits and the '_' character.
// The first letter of the varname must not be a digit.
// The record field must have the form “key = value”, where key is a non-empty varname.
// The value contains any valid utf-8 sequence.
// Record names and keys can be non-unique. Then they will be interpreted as arrays.
//
// The mini format does not specify data types of values.
// But this decoder works only with string, int, bool and time.Duration.
// You should use `mini:"name"` tag to designate a structure field.
// You can use the `mini-required:"true"` tag for mandatory fields.
// You can use the `mini-default:"value"` tag for default values.
func Decode(r io.Reader, v any) error {
rb := bufio.NewReader(r)
m := newMachine()
Expand Down

0 comments on commit aa4808e

Please sign in to comment.