Skip to content

Can I get the original value if variable empty #56

Open
@jLopezbarb

Description

@jLopezbarb

Hi, I need to know if there is a variable in my text that is empty after expanding it. I need those variables not to expand and use the original string.

os.Setenv("GREETINGS", "hello")
value := "$GREETINGS $NAME"
result, err := envsubst.String(value)
if err != nil {
	return "", fmt.Errorf("error expanding environment on '%s': %s", value, err.Error())
}
fmt.Println(result) // The output is: "hello "

Is there a way of getting hello $NAME as the output?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions