Skip to content

a place in goconfig misleading me #58

@tw4452852

Description

@tw4452852

Hi,
Today, I read revel's src, and find a place in goconfig that I can't understand. Can you help me?
in goconfig/config/read.go Line93, why getting the index of "=:" twice, I think inner one is same as the outer one.

// Other alternatives
        default:
            i := strings.IndexAny(l, "=:")

            switch {
            // Option and value
            case i > 0:
                i := strings.IndexAny(l, "=:")
                option = strings.TrimSpace(l[0:i])
                value := strings.TrimSpace(stripComments(l[i+1:]))
                self.AddOption(section, option, value)
            // Continuation of multi-line value
            case section != "" && option != "":
                prev, _ := self.RawString(section, option)
                value := strings.TrimSpace(stripComments(l))
                self.AddOption(section, option, prev+"\n"+value)

            default:
                return errors.New("could not parse line: " + l)
            }
        }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions