Skip to content

Commit

Permalink
fix: #351, need to do proper interface checking since the cfg can com…
Browse files Browse the repository at this point in the history
…e in as 2 different types
  • Loading branch information
zaquestion committed Dec 11, 2019
1 parent 0e33267 commit c875a07
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions cmd/snippet_browse.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,17 @@ var snippetBrowseCmd = &cobra.Command{
}

c := viper.AllSettings()["core"]
config := c.([]map[string]interface{})[0]
host := config["host"].(string)
var cfg map[string]interface{}
switch v := c.(type) {
// Most run this is the type
case []map[string]interface{}:
cfg = v[0]
// On the first run when the cfg is created it comes in as this type
// for whatever reason
case map[string]interface{}:
cfg = v
}
host := cfg["host"].(string)
hostURL, err := url.Parse(host)
if err != nil {
log.Fatal(err)
Expand Down

0 comments on commit c875a07

Please sign in to comment.