declare constants in golang using os.Getenv results in ‘const initializer in os.Getenv(“MY_SECRET”) is not a constant’

Just like the error says, a constant must have a constant value. You cannot set it to the return of a function. It must be evaluated at compile time (e.g. a string literal). If you want to store the values of environment variables looked up at run time, you’ll have to store them in variables, not constants.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)