Configure a default directory path in Go with Cobra and Viper

Viewed 149

I want the user of my CLI app to enter a specific path where they want to save files. I tried to use Cobra's --config flag but I don't know how to.

Example:

app --config path "~/Documents/"

How could I do this?

1 Answers

You could try to sepcify a absolute path.

app --config path "$HOME/Documents/"
Related