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

Behaviour deviates from Node dotenv #241

Open
harishnair96 opened this issue Feb 26, 2025 · 0 comments
Open

Behaviour deviates from Node dotenv #241

harishnair96 opened this issue Feb 26, 2025 · 0 comments

Comments

@harishnair96
Copy link

I am using the following code to compare the difference in behaviour.

require('dotenv').config()

console.log(process.env.TEST_ENV)
package main

import (
	"fmt"
	"os"

	"github.com/joho/godotenv"
)

func main() {
	if err := godotenv.Load(); err != nil {
		fmt.Fprintln(os.Stderr, err)
	}
	fmt.Println(os.Getenv("TEST_ENV"))
}
  1. Double quotes without escape

    TEST_ENV="test"test"

    Node dotenv worked but godotenv failed to even parse the env file.

    Image
  2. Double quotes with escape

    TEST_ENV="test\"test"    

    Node dotenv parsed the value literally but gotdotenv used \ to escape the double quote.

    Image
  3. Exclamation mark with escape

    TEST_ENV="test\!test"

    Node dotenv parsed the value literally but godotenv used \ to escape the exclamation mark.

    Image

    An additional point here is that both the libraries parses exclamation marks without escape as well.

    TEST_ENV="test!test"
    Image

    However godotenv escapes exclamation during marshalling.

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

1 participant