~edwargix/tallyard

3dd4bd626dc87bd1fb33f060e65170237ac68e33 — David Florness 1 year, 8 months ago 7e309c5
Switch from github.com/kyoh86/xdg to github.com/adrg/xdg

The former was officially deprecated: <https://github.com/kyoh86/xdg/commit/6e325b3eaba4>

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 <david@florness.com>
6 files changed, 14 insertions(+), 13 deletions(-)

M cmd/tallyard/auth.go
M cmd/tallyard/main.go
M election/marshal.go
M election/utils.go
M go.mod
M go.sum
M cmd/tallyard/auth.go => cmd/tallyard/auth.go +2 -2
@@ 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) {

M cmd/tallyard/main.go => cmd/tallyard/main.go +3 -3
@@ 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")

M election/marshal.go => election/marshal.go +3 -3
@@ 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 {

M election/utils.go => election/utils.go +2 -2
@@ 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

M go.mod => go.mod +1 -1
@@ 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

M go.sum => go.sum +3 -2
@@ 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=