Skip to content

Commit

Permalink
fix type assertion panic
Browse files Browse the repository at this point in the history
  • Loading branch information
mpl committed Jul 25, 2024
1 parent bc0b684 commit 1822dbd
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions notecard/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ type server struct {
initError error
}

func getEnv(key string, fallback any) any {
func getEnv(key string, fallback string) string {
if value, ok := os.LookupEnv(key); ok {
return value
}
Expand Down Expand Up @@ -108,7 +108,7 @@ func setupNotecard(protocol string) (*notecard.Context, error) {
}

func main() {
debug, err := strconv.ParseBool(getEnv("NOTECARD_DEBUG", false).(string))
debug, err := strconv.ParseBool(getEnv("NOTECARD_DEBUG", "false"))
if err != nil {
log.Printf("Error parsing NOTECARD_DEBUG: %v", err)
}
Expand All @@ -117,7 +117,7 @@ func main() {
log.Printf("Debug mode enabled")
}

transport := getEnv("NOTECARD_TRANSPORT", I2C).(string)
transport := getEnv("NOTECARD_TRANSPORT", I2C)

card, err := setupNotecard(transport)
if err != nil {
Expand Down

0 comments on commit 1822dbd

Please sign in to comment.