Skip to content

Not reading my .env file #181

Closed
Closed

Description

@tausyy

I have my .env file with 2 properties

BOT_TOKEN=rightHereIsWhereMyTokenIs
TEST=1234

when I go run main.go with this code this is my output

env: environment variable "BOT_TOKEN" should not be empty
{BotToken: Test:0}

What am I doing wrong?

package main

import (
	"fmt"

	"github.com/caarlos0/env/v6"
)

type config struct {
	BotToken string `env:"BOT_TOKEN,notEmpty"`
	Test     int32  `env:"TEST"`
}

func main() {
	cfg := config{}
	if err := env.Parse(&cfg); err != nil {
		fmt.Printf("%+v\n", err)
	}

	fmt.Printf("%+v\n", cfg)
}

Activity

  1. Repository owner locked and limited conversation to collaborators on Jun 9, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions