File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11package config
22
33import (
4- "os"
5- "path/filepath"
4+ "github.com/kirsle/configdir"
65
76 "github.com/crowdsecurity/ipdex/pkg/display"
87)
@@ -20,19 +19,21 @@ var CacheFolder string
2019var ConfigFolder string
2120
2221func GetCacheFolder () (string , error ) {
23- home , err := os .UserHomeDir ()
22+ cachePath := configdir .LocalCache ("ipdex" )
23+ err := configdir .MakePath (cachePath )
2424 if err != nil {
2525 return "" , err
2626 }
27- return filepath . Join ( home , ".cache" , "ipdex" ) , nil
27+ return cachePath , nil
2828}
2929
3030func GetConfigFolder () (string , error ) {
31- home , err := os .UserHomeDir ()
31+ configPath := configdir .LocalConfig ("ipdex" )
32+ err := configdir .MakePath (configPath )
3233 if err != nil {
3334 return "" , err
3435 }
35- return filepath . Join ( home , ".config" , "ipdex" ) , nil
36+ return configPath , nil
3637}
3738
3839func IsSupportedOutputFormat (outputFormat string ) bool {
Original file line number Diff line number Diff line change @@ -33,6 +33,7 @@ require (
3333 github.com/jinzhu/inflection v1.0.0 // indirect
3434 github.com/jinzhu/now v1.1.5 // indirect
3535 github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 // indirect
36+ github.com/kirsle/configdir v0.0.0-20170128060238-e45d2f54772f // indirect
3637 github.com/lithammer/fuzzysearch v1.1.8 // indirect
3738 github.com/lucasb-eyer/go-colorful v1.2.0 // indirect
3839 github.com/magiconair/properties v1.8.9 // indirect
Original file line number Diff line number Diff line change @@ -74,6 +74,8 @@ github.com/jinzhu/now v1.1.5 h1:/o9tlHleP7gOFmsnYNz3RGnqzefHA47wQpKrrdTIwXQ=
7474github.com/jinzhu/now v1.1.5 /go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8 =
7575github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 h1:Z9n2FFNUXsshfwJMBgNA0RU6/i7WVaAegv3PtuIHPMs =
7676github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 /go.mod h1:CzGEWj7cYgsdH8dAjBGEr58BoE7ScuLd+fwFZ44+/x8 =
77+ github.com/kirsle/configdir v0.0.0-20170128060238-e45d2f54772f h1:dKccXx7xA56UNqOcFIbuqFjAWPVtP688j5QMgmo6OHU =
78+ github.com/kirsle/configdir v0.0.0-20170128060238-e45d2f54772f /go.mod h1:4rEELDSfUAlBSyUjPG0JnaNGjf13JySHFeRdD/3dLP0 =
7779github.com/klauspost/cpuid/v2 v2.0.9 /go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg =
7880github.com/klauspost/cpuid/v2 v2.0.10 /go.mod h1:g2LTdtYhdyuGPqyWyv7qRAmj1WBqxuObKfj5c0PQa7c =
7981github.com/klauspost/cpuid/v2 v2.0.12 /go.mod h1:g2LTdtYhdyuGPqyWyv7qRAmj1WBqxuObKfj5c0PQa7c =
Original file line number Diff line number Diff line change @@ -2,10 +2,11 @@ package version
22
33import (
44 "fmt"
5+ "runtime/debug"
56)
67
78const (
8- LatestVersion = "v0.0.8 "
9+ LatestVersion = "v0.0.10 "
910)
1011
1112var (
@@ -20,6 +21,11 @@ func FullString() string {
2021}
2122
2223func String () string {
24+ if info , ok := debug .ReadBuildInfo (); ok {
25+ if Version == "" {
26+ Version = info .Main .Version
27+ }
28+ }
2329 if Version == "" {
2430 Version = LatestVersion
2531 }
You can’t perform that action at this time.
0 commit comments