Skip to content

White space between variable name and equal sign "=" not supported #7

@gwolffblues

Description

@gwolffblues

If the .env file has a field written as

MY_VAR_NAME = my_value

the parsing to a struct will fail because the struct fields cannot contain whitespaces

Recommend adding a test case here:

DB_PASS=" mypass "

MY_VAR = my_value

Possible Solution:
Change

expr = "(?<key>.+?)=(?<value>.*)";

to

expr = "(?<key>.+?)\s*=\s*(?<value>.*)";

could also use STRTRIM on the resulting key/value string results instead

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