Skip to content

Commit

Permalink
util: move token file to $XDG_CONFIG_HOME
Browse files Browse the repository at this point in the history
  • Loading branch information
msfjarvis committed Jun 1, 2022
1 parent 77f570f commit ef37065
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 9 deletions.
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ module github.com/msfjarvis/gdrive
go 1.16

require (
github.com/adrg/xdg v0.3.3 // indirect
github.com/sabhiram/go-gitignore v0.0.0-20201211210132-54b8a0bf510f
github.com/soniakeys/graph v0.0.0-20160409104831-c265d9676750
github.com/stretchr/testify v1.7.0 // indirect
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ cloud.google.com/go/storage v1.10.0/go.mod h1:FLPqc6j+Ki4BU591ie1oL6qBQGu2Bl/tZ9
dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU=
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo=
github.com/adrg/xdg v0.3.3 h1:s/tV7MdqQnzB1nKY8aqHvAMD+uCiuEDzVB5HLRY849U=
github.com/adrg/xdg v0.3.3/go.mod h1:61xAR2VZcggl2St4O9ohF5qCKe08+JDmE4VNzPFQvOQ=
github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI=
github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI=
Expand Down
12 changes: 3 additions & 9 deletions util.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,18 @@ import (
"io"
"os"
"path/filepath"
"runtime"

"github.com/adrg/xdg"
)

func GetDefaultConfigDir() string {
return filepath.Join(Homedir(), ".gdrive")
return filepath.Join(xdg.ConfigHome, "gdrive")
}

func ConfigFilePath(basePath, name string) string {
return filepath.Join(basePath, name)
}

func Homedir() string {
if runtime.GOOS == "windows" {
return os.Getenv("APPDATA")
}
return os.Getenv("HOME")
}

func equal(a, b []string) bool {
if a == nil && b == nil {
return true
Expand Down

0 comments on commit ef37065

Please sign in to comment.