Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

parse include "$" line error #171

Open
kasuganosora opened this issue Mar 4, 2022 · 3 comments
Open

parse include "$" line error #171

kasuganosora opened this issue Mar 4, 2022 · 3 comments

Comments

@kasuganosora
Copy link

m, err := godotenv.Unmarshal("MAIL_PASSWORD=cy8$V2dABC")
assert.Nil(t, err)
assert.Equal(t, "cy8$V2dABC", m["MAIL_PASSWORD"])

Expected :cy8$V2dABC
Actual :cy8dABC

@parth-khiera
Copy link

parth-khiera commented Mar 9, 2022

works for me if escaped $

so basically it's cy8\$V2dABC, for you

@cgxxv
Copy link

cgxxv commented Jul 4, 2023

Ya, I have spent a few hours for debugging this, it cause me a lot of pain, do we have any better solution?

@AliiAhmadi
Copy link

m, err := godotenv.Unmarshal("MAIL_PASSWORD=cy8$V2dABC")
assert.Nil(t, err)
assert.Equal(t, "cy8$V2dABC", m["MAIL_PASSWORD"])

Expected :cy8$V2dABC Actual :cy8dABC

You can also handle it by using single quotes.
your .env file:

PASS='cy8$V2dABC'

And you can access PASS simply like this:

package main

import (
	"fmt"
	"os"

	_ "github.com/joho/godotenv/autoload"
)

func main() {
	fmt.Println("PASS:", os.Getenv("PASS")) // PASS: cy8$V2dABC
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants