-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Closed
Labels
kind/bugSomething isn't workingSomething isn't working
Description
Preflight Checklist
- I have searched the issue tracker for an issue that matches the one I want to file, without success.
- I am not looking for support or already pursued the available support channels without success.
- I have checked the troubleshooting guide for my problem, without success.
Viper Version
1.15.0
Go Version
1.20.1
Config Source
Environment variables
Format
Other (specify below)
Repl.it link
No response
Code reproducing the issue
package main
import (
"fmt"
"log"
"github.com/spf13/viper"
)
type Config struct {
FbClientId string `mapstructure:"FB_CLIENT_ID"`
}
func LoadConfig() (config Config, err error) {
viper.AutomaticEnv()
err = viper.Unmarshal(&config)
if err != nil {
return
}
return
}
func main() {
type Config struct {
FbClientId string `mapstructure:"FB_CLIENT_ID"`
}
cfg, err := LoadConfig()
if err != nil {
log.Fatal(err)
}
fmt.Print(cfg.FbClientId)
}Expected Behavior
After running this command, I expect fmt.Print(cfg.FbClientId) to log 123:
export FB_CLIENT_ID="123" && go run main.goActual Behavior
There is no output in the console.
Steps To Reproduce
No response
Additional Information
No response
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
kind/bugSomething isn't workingSomething isn't working