From 3dd4bd626dc87bd1fb33f060e65170237ac68e33 Mon Sep 17 00:00:00 2001 From: David Florness Date: Wed, 1 Mar 2023 21:05:36 -0500 Subject: [PATCH] Switch from github.com/kyoh86/xdg to github.com/adrg/xdg The former was officially deprecated: Note that although the old package was deprecated because it recommends using os.UserXXXDir function from the standard library, as of golang 1.20 there is no standard library function in the os library for the user data dir that we need (XDG_DATA_HOME on unix). Signed-off-by: David Florness --- cmd/tallyard/auth.go | 4 ++-- cmd/tallyard/main.go | 6 +++--- election/marshal.go | 6 +++--- election/utils.go | 4 ++-- go.mod | 2 +- go.sum | 5 +++-- 6 files changed, 14 insertions(+), 13 deletions(-) diff --git a/cmd/tallyard/auth.go b/cmd/tallyard/auth.go index e55a5da..8d42c4b 100644 --- a/cmd/tallyard/auth.go +++ b/cmd/tallyard/auth.go @@ -10,7 +10,7 @@ import ( "os" "syscall" - "github.com/kyoh86/xdg" + "github.com/adrg/xdg" "golang.org/x/crypto/ssh/terminal" "maunium.net/go/mautrix" "maunium.net/go/mautrix/id" @@ -24,7 +24,7 @@ type AuthInfo struct { Username string `json:"username"` } -var authFname = xdg.DataHome() + "/tallyard/auth.json" +var authFname = xdg.DataHome + "/tallyard/auth.json" func GetAuthInfo() (authInfo *AuthInfo, err error) { if _, err = os.Stat(authFname); os.IsNotExist(err) { diff --git a/cmd/tallyard/main.go b/cmd/tallyard/main.go index 4378b91..a0f4315 100644 --- a/cmd/tallyard/main.go +++ b/cmd/tallyard/main.go @@ -12,9 +12,9 @@ import ( "runtime/debug" "time" + "github.com/adrg/xdg" "github.com/consensys/gnark-crypto/ecc/bls12-381/fr" gnarkLogger "github.com/consensys/gnark/logger" - "github.com/kyoh86/xdg" log "github.com/sirupsen/logrus" "maunium.net/go/mautrix" "maunium.net/go/mautrix/event" @@ -29,7 +29,7 @@ import ( var ( noRedact bool - dataDir = xdg.DataHome() + "/tallyard" + dataDir = xdg.DataHome + "/tallyard" electionsFname = dataDir + "/elections.json" logsFname = dataDir + "/tallyard.log" ) @@ -84,7 +84,7 @@ func main() { fmt.Println(" will remove your personal records of any of your concluded/in-progress") fmt.Println(" elections!!") fmt.Println() - fmt.Printf (" rm %s/tallyard/elections.json\n", xdg.DataHome()) + fmt.Printf (" rm %s/tallyard/elections.json\n", xdg.DataHome) fmt.Println(" tallyard") fmt.Println() fmt.Println("2. downgrade tallyard to a previous version that supports your election") diff --git a/election/marshal.go b/election/marshal.go index 262cc78..2b1fde2 100644 --- a/election/marshal.go +++ b/election/marshal.go @@ -5,19 +5,19 @@ package election import ( "os" + "github.com/adrg/xdg" "github.com/consensys/gnark-crypto/ecc" "github.com/consensys/gnark/backend/groth16" - "github.com/kyoh86/xdg" log "github.com/sirupsen/logrus" "maunium.net/go/mautrix/util" ) func init() { - os.MkdirAll(xdg.DataHome() + "/tallyard/files", 0700) + os.MkdirAll(xdg.DataHome+"/tallyard/files", 0700) } func filePath(fileID string) string { - return xdg.DataHome() + "/tallyard/files/" + fileID + return xdg.DataHome + "/tallyard/files/" + fileID } type ProvingKeyFile struct { diff --git a/election/utils.go b/election/utils.go index 83fcf56..afe2bb4 100644 --- a/election/utils.go +++ b/election/utils.go @@ -9,7 +9,7 @@ import ( "os" "time" - "github.com/kyoh86/xdg" + "github.com/adrg/xdg" log "github.com/sirupsen/logrus" "maunium.net/go/mautrix/crypto/canonicaljson" "maunium.net/go/mautrix/crypto/olm" @@ -18,7 +18,7 @@ import ( ) func LogUpload(contentURI id.ContentURI) { - file, err := os.OpenFile(xdg.DataHome() + "/tallyard/uploads.tsv", os.O_CREATE|os.O_WRONLY|os.O_APPEND, 0600) + file, err := os.OpenFile(xdg.DataHome+"/tallyard/uploads.tsv", os.O_CREATE|os.O_WRONLY|os.O_APPEND, 0600) if err != nil { log.Warnf("couldn't open uploads file: %s", err) return diff --git a/go.mod b/go.mod index 0e40561..f80f828 100644 --- a/go.mod +++ b/go.mod @@ -3,10 +3,10 @@ module tallyard.xyz go 1.18 require ( + github.com/adrg/xdg v0.4.0 github.com/consensys/gnark v0.7.1 github.com/consensys/gnark-crypto v0.7.0 github.com/gdamore/tcell/v2 v2.6.0 - github.com/kyoh86/xdg v1.2.0 github.com/rivo/tview v0.0.0-20230203122838-f0550c7918da github.com/sirupsen/logrus v1.9.0 golang.org/x/crypto v0.6.0 diff --git a/go.sum b/go.sum index ce2e11c..0d04a1b 100644 --- a/go.sum +++ b/go.sum @@ -1,3 +1,5 @@ +github.com/adrg/xdg v0.4.0 h1:RzRqFcjH4nE5C6oTAxhBtoE2IRyjBSa62SCbyPidvls= +github.com/adrg/xdg v0.4.0/go.mod h1:N6ag73EX4wyxeaoeHctc1mas01KZgsj5tYiAIwqJE/E= github.com/consensys/gnark v0.7.1 h1:0ZWY9uKhhznRn541ptjdt0XxriOp1ikAubAkHahoJyQ= github.com/consensys/gnark v0.7.1/go.mod h1:oQnMurInsfe+9rG4l8qh8AFVihfuRCS5H3XPJH/6HPM= github.com/consensys/gnark-crypto v0.7.0 h1:rwdy8+ssmLYRqKp+ryRRgQJl/rCq2uv+n83cOydm5UE= @@ -14,8 +16,6 @@ github.com/gdamore/tcell/v2 v2.6.0 h1:OKbluoP9VYmJwZwq/iLb4BxwKcwGthaa1YNBJIyCyS github.com/gdamore/tcell/v2 v2.6.0/go.mod h1:be9omFATkdr0D9qewWW3d+MEvl5dha+Etb5y65J2H8Y= github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= github.com/google/subcommands v1.2.0/go.mod h1:ZjhPrFU+Olkh9WazFPsl27BQ4UPiG37m3yTrtFlrHVk= -github.com/kyoh86/xdg v1.2.0 h1:CERuT/ShdTDj+A2UaX3hQ3mOV369+Sj+wyn2nIRIIkI= -github.com/kyoh86/xdg v1.2.0/go.mod h1:/mg8zwu1+qe76oTFUBnyS7rJzk7LLC0VGEzJyJ19DHs= github.com/leanovate/gopter v0.2.9 h1:fQjYxZaynp97ozCzfOyOuAGOU4aU/z37zf/tOujFk7c= github.com/lucasb-eyer/go-colorful v1.2.0 h1:1nnpGOrhyZZuNyfu1QjKiUICQ74+3FNCN69Aj6K7nkY= github.com/lucasb-eyer/go-colorful v1.2.0/go.mod h1:R4dSotOR9KMtayYi1e77YzuveK+i7ruzyGqttikkLy0= @@ -79,6 +79,7 @@ golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20211025201205-69cdffdb9359/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -- 2.38.4