File tree Expand file tree Collapse file tree 2 files changed +8
-7
lines changed Expand file tree Collapse file tree 2 files changed +8
-7
lines changed Original file line number Diff line number Diff line change @@ -2,21 +2,22 @@ package main
22
33import (
44 "encoding/json"
5+ "github.com/mitchellh/go-homedir"
56 "github.com/spf13/viper"
67 "os"
7- "os/user"
88 "path/filepath"
99)
1010
1111type config struct {
1212 AccessToken string `json:"accessToken"`
13+ ID string `json:"id"`
1314}
1415
15- var C config
16+ var marshaledConfig config
1617
1718func getDefaultConfigPath () string {
18- currentUser , _ := user . Current ()
19- return filepath .Join (currentUser . HomeDir , "Library/Application Support/Alfred 2/Workflow Data/" , bundleId )
19+ homeDir , _ := homedir . Dir ()
20+ return filepath .Join (homeDir , "Library/Application Support/Alfred 2/Workflow Data/" , bundleID )
2021}
2122
2223func loadConfig () error {
@@ -33,9 +34,9 @@ func loadConfig() error {
3334
3435func saveConfig () error {
3536 configPath := getDefaultConfigPath ()
36- viper .Marshal ( & C )
37+ viper .Unmarshal ( & marshaledConfig )
3738
38- buf , err := json .MarshalIndent (C , "" , " " )
39+ buf , err := json .MarshalIndent (marshaledConfig , "" , " " )
3940 if err != nil {
4041 return err
4142 }
Original file line number Diff line number Diff line change 99)
1010
1111const (
12- bundleId = "co.randompaper.alfred-qiita-workflow"
12+ bundleID = "co.randompaper.alfred-qiita-workflow"
1313 version = "2.0.0"
1414)
1515
You can’t perform that action at this time.
0 commit comments