xepobopa
HOBBYOP
8 months ago
All my code on GoLang works well, but i cannot get .env vars in code.
I do it like this
func GetDotenv(names ...string) ([]string, error) {
if err := godotenv.Load(); err != nil {
return []string{}, fmt.Errorf("error trying to get .env var: %w", err)
}
var vars []string
for idx, name := range names {
vars[idx] = os.Getenv(name)
}
return vars, nil
}and i do not get anything. I also tried to specify .env path , but it also didnt work. But error error trying to get .env var: do not fire, it just return me empty list
0 Replies
I used a different go library
endpointSecret := os.Getenv("STRIPE_WEBHOOK_SIGNING_SECRET") // Set this in .env
event, err := webhook.ConstructEvent(body, sigHeader, endpointSecret)brody
EMPLOYEE
8 months ago
you dont need to use any libray, only os.Getenv
brody
EMPLOYEE
8 months ago
we do not inject variables as a .env file, they are injected directly into the environment
brody
EMPLOYEE
8 months ago
!s
Status changed to Solved brody • 8 months ago