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"))
}
-
Double quotes without escape
Node dotenv worked but godotenv failed to even parse the env file.
-
Double quotes with escape
Node dotenv parsed the value literally but gotdotenv used \ to escape the double quote.
-
Exclamation mark with escape
Node dotenv parsed the value literally but godotenv used \ to escape the exclamation mark.
An additional point here is that both the libraries parses exclamation marks without escape as well.
However godotenv escapes exclamation during marshalling.
I am using the following code to compare the difference in behaviour.
Double quotes without escape
Node dotenv worked but godotenv failed to even parse the env file.
Double quotes with escape
Node dotenv parsed the value literally but gotdotenv used
\to escape the double quote.Exclamation mark with escape
Node dotenv parsed the value literally but godotenv used
\to escape the exclamation mark.An additional point here is that both the libraries parses exclamation marks without escape as well.
However godotenv escapes exclamation during marshalling.