I have two configurations in the .env
file as following
MAX_TOKEN_EXPIRY_DAYS=30d
ACCESS_TOKEN_DURATION=30m
The struct in golang to load the config looks like following
type AppConfig struct {
MaxTokenExpiry time.Duration `mapstructure:"MAX_TOKEN_EXPIRY_DAYS"`
AccessTokenDuration time.Duration `mapstructure:"ACCESS_TOKEN_DURATION"`
}
Now the when I am trying to load the config, I am getting the following error
* error decoding 'MAX_TOKEN_EXPIRY_DAYS': time: unknown unit "d" in duration "30d"
This may mean that I the issue was with MAX_TOKEN_EXPIRY_DAYS=30d
line as it is not able to recognise the d
tag. But the m
tag in ACCESS_TOKEN_DURATION=30m
runs well as time.Duration
in golang is able to parse it well.
In the time package source code, I see the following constructs
Nanosecond Duration = 1
Microsecond = 1000 * Nanosecond
Millisecond = 1000 * Microsecond
Second = 1000 * Millisecond
Minute = 60 * Second
Hour = 60 * Minute
Is there any way to denote days in the config?