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

fix: ignore all errors when reading dotenv for experiments #1245

Merged
merged 1 commit into from
Jun 30, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
16 changes: 3 additions & 13 deletions internal/experiments/experiments.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package experiments

import (
"errors"
"fmt"
"os"
"strings"
Expand All @@ -17,9 +16,7 @@ const envPrefix = "TASK_X_"
var GentleForce bool

func init() {
if err := readDotEnv(); err != nil {
panic(err)
}
readDotEnv()
GentleForce = parseEnv("GENTLE_FORCE")
}

Expand All @@ -28,21 +25,14 @@ func parseEnv(xName string) bool {
return os.Getenv(envName) == "1"
}

func readDotEnv() error {
env, err := godotenv.Read()
if errors.Is(err, os.ErrNotExist) {
return nil
}
if err != nil {
return err
}
func readDotEnv() {
env, _ := godotenv.Read()
// If the env var is an experiment, set it.
for key, value := range env {
if strings.HasPrefix(key, envPrefix) {
os.Setenv(key, value)
}
}
return nil
}

func List(l *logger.Logger) error {
Expand Down