🚨 go fmt; go mod tidy
This commit is contained in:
parent
fb2a29be51
commit
b0657a3fb2
20 changed files with 715 additions and 722 deletions
|
@ -66,11 +66,11 @@ var newCmd = &cli.Command{
|
||||||
var d time.Time
|
var d time.Time
|
||||||
switch deadlineUnit {
|
switch deadlineUnit {
|
||||||
case "m", "":
|
case "m", "":
|
||||||
d = time.Now().UTC().Add(time.Duration(deadlineInt)*time.Minute).Round(time.Second)
|
d = time.Now().UTC().Add(time.Duration(deadlineInt) * time.Minute).Round(time.Second)
|
||||||
case "h":
|
case "h":
|
||||||
d = time.Now().UTC().Add(time.Duration(deadlineInt)*time.Hour).Round(time.Second)
|
d = time.Now().UTC().Add(time.Duration(deadlineInt) * time.Hour).Round(time.Second)
|
||||||
case "d":
|
case "d":
|
||||||
d = time.Now().UTC().Add(time.Duration(deadlineInt)*time.Hour*24).Round(time.Second)
|
d = time.Now().UTC().Add(time.Duration(deadlineInt) * time.Hour * 24).Round(time.Second)
|
||||||
default:
|
default:
|
||||||
panic("this code should never be reached")
|
panic("this code should never be reached")
|
||||||
}
|
}
|
||||||
|
|
1
go.mod
1
go.mod
|
@ -13,7 +13,6 @@ require (
|
||||||
require (
|
require (
|
||||||
github.com/cpuguy83/go-md2man/v2 v2.0.4 // indirect
|
github.com/cpuguy83/go-md2man/v2 v2.0.4 // indirect
|
||||||
github.com/dgrijalva/jwt-go v3.2.0+incompatible // indirect
|
github.com/dgrijalva/jwt-go v3.2.0+incompatible // indirect
|
||||||
github.com/labstack/echo/v4 v4.12.0 // indirect
|
|
||||||
github.com/labstack/gommon v0.4.2 // indirect
|
github.com/labstack/gommon v0.4.2 // indirect
|
||||||
github.com/mattn/go-colorable v0.1.13 // indirect
|
github.com/mattn/go-colorable v0.1.13 // indirect
|
||||||
github.com/mattn/go-isatty v0.0.20 // indirect
|
github.com/mattn/go-isatty v0.0.20 // indirect
|
||||||
|
|
4
go.sum
4
go.sum
|
@ -8,8 +8,6 @@ github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
|
||||||
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||||
github.com/labstack/echo v3.3.10+incompatible h1:pGRcYk231ExFAyoAjAfD85kQzRJCRI8bbnE7CX5OEgg=
|
github.com/labstack/echo v3.3.10+incompatible h1:pGRcYk231ExFAyoAjAfD85kQzRJCRI8bbnE7CX5OEgg=
|
||||||
github.com/labstack/echo v3.3.10+incompatible/go.mod h1:0INS7j/VjnFxD4E2wkz67b8cVwCLbBmJyDaka6Cmk1s=
|
github.com/labstack/echo v3.3.10+incompatible/go.mod h1:0INS7j/VjnFxD4E2wkz67b8cVwCLbBmJyDaka6Cmk1s=
|
||||||
github.com/labstack/echo/v4 v4.12.0 h1:IKpw49IMryVB2p1a4dzwlhP1O2Tf2E0Ir/450lH+kI0=
|
|
||||||
github.com/labstack/echo/v4 v4.12.0/go.mod h1:UP9Cr2DJXbOK3Kr9ONYzNowSh7HP0aG0ShAyycHSJvM=
|
|
||||||
github.com/labstack/gommon v0.4.2 h1:F8qTUNXgG1+6WQmqoUWnz8WiEU60mXVVw0P4ht1WRA0=
|
github.com/labstack/gommon v0.4.2 h1:F8qTUNXgG1+6WQmqoUWnz8WiEU60mXVVw0P4ht1WRA0=
|
||||||
github.com/labstack/gommon v0.4.2/go.mod h1:QlUFxVM+SNXhDL/Z7YhocGIBYOiwB0mXm1+1bAPHPyU=
|
github.com/labstack/gommon v0.4.2/go.mod h1:QlUFxVM+SNXhDL/Z7YhocGIBYOiwB0mXm1+1bAPHPyU=
|
||||||
github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA=
|
github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA=
|
||||||
|
@ -35,8 +33,6 @@ github.com/xrash/smetrics v0.0.0-20240312152122-5f08fbb34913 h1:+qGGcbkzsfDQNPPe
|
||||||
github.com/xrash/smetrics v0.0.0-20240312152122-5f08fbb34913/go.mod h1:4aEEwZQutDLsQv2Deui4iYQ6DWTxR14g6m8Wv88+Xqk=
|
github.com/xrash/smetrics v0.0.0-20240312152122-5f08fbb34913/go.mod h1:4aEEwZQutDLsQv2Deui4iYQ6DWTxR14g6m8Wv88+Xqk=
|
||||||
golang.org/x/crypto v0.23.0 h1:dIJU/v2J8Mdglj/8rJ6UUOM3Zc9zLZxVZwwxMooUSAI=
|
golang.org/x/crypto v0.23.0 h1:dIJU/v2J8Mdglj/8rJ6UUOM3Zc9zLZxVZwwxMooUSAI=
|
||||||
golang.org/x/crypto v0.23.0/go.mod h1:CKFgDieR+mRhux2Lsu27y0fO304Db0wZe70UKqHu0v8=
|
golang.org/x/crypto v0.23.0/go.mod h1:CKFgDieR+mRhux2Lsu27y0fO304Db0wZe70UKqHu0v8=
|
||||||
golang.org/x/net v0.21.0 h1:AQyQV4dYCvJ7vGmJyKki9+PBdyvhkSd8EIx/qb0AYv4=
|
|
||||||
golang.org/x/net v0.21.0/go.mod h1:bIjVDfnllIU7BJ2DNgfnXvpSvtn8VRwhlsaeUTyUS44=
|
|
||||||
golang.org/x/net v0.24.0 h1:1PcaxkF854Fu3+lvBIx5SYn9wRlBzzcnHZSiaFFAb0w=
|
golang.org/x/net v0.24.0 h1:1PcaxkF854Fu3+lvBIx5SYn9wRlBzzcnHZSiaFFAb0w=
|
||||||
golang.org/x/net v0.24.0/go.mod h1:2Q7sJY5mzlzWjKtYUEXSlBWCdyaioyXzRB2RtU8KVE8=
|
golang.org/x/net v0.24.0/go.mod h1:2Q7sJY5mzlzWjKtYUEXSlBWCdyaioyXzRB2RtU8KVE8=
|
||||||
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
|
|
|
@ -40,7 +40,7 @@ func handleIndex(ctx echo.Context) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func handleNewVoting(ctx echo.Context) error {
|
func handleNewVoting(ctx echo.Context) error {
|
||||||
id :=utils.GenerateRandomString(11)
|
id := utils.GenerateRandomString(11)
|
||||||
var (
|
var (
|
||||||
formReferendum = ctx.FormValue("referendum")
|
formReferendum = ctx.FormValue("referendum")
|
||||||
formDeadline = ctx.FormValue("deadline")
|
formDeadline = ctx.FormValue("deadline")
|
||||||
|
@ -69,11 +69,11 @@ func handleNewVoting(ctx echo.Context) error {
|
||||||
}
|
}
|
||||||
switch deadlineUnit {
|
switch deadlineUnit {
|
||||||
case "m", "":
|
case "m", "":
|
||||||
d = time.Now().UTC().Add(time.Duration(deadlineInt)*time.Minute).Round(time.Second)
|
d = time.Now().UTC().Add(time.Duration(deadlineInt) * time.Minute).Round(time.Second)
|
||||||
case "h":
|
case "h":
|
||||||
d = time.Now().UTC().Add(time.Duration(deadlineInt)*time.Hour).Round(time.Second)
|
d = time.Now().UTC().Add(time.Duration(deadlineInt) * time.Hour).Round(time.Second)
|
||||||
case "d":
|
case "d":
|
||||||
d = time.Now().UTC().Add(time.Duration(deadlineInt)*time.Hour*24).Round(time.Second)
|
d = time.Now().UTC().Add(time.Duration(deadlineInt) * time.Hour * 24).Round(time.Second)
|
||||||
default:
|
default:
|
||||||
panic("this code should never be reached")
|
panic("this code should never be reached")
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,4 +18,3 @@ func init() {
|
||||||
initCreateTables(db)
|
initCreateTables(db)
|
||||||
initStmts(db)
|
initStmts(db)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -174,7 +174,7 @@ func (v *Voting) Vote(vote vote.Vote) error {
|
||||||
func (v Voting) Votes() []vote.Vote {
|
func (v Voting) Votes() []vote.Vote {
|
||||||
votes := []vote.Vote{}
|
votes := []vote.Vote{}
|
||||||
nextVote:
|
nextVote:
|
||||||
for i := len(v.votes)-1; i >= 0; i-- {
|
for i := len(v.votes) - 1; i >= 0; i-- {
|
||||||
elector := v.votes[i].Elector
|
elector := v.votes[i].Elector
|
||||||
for _, e := range votes {
|
for _, e := range votes {
|
||||||
if e.Elector == elector {
|
if e.Elector == elector {
|
||||||
|
@ -200,4 +200,3 @@ func (v Voting) abstainVotes() []vote.Vote {
|
||||||
filterFunc := func(_v vote.Vote) bool { return _v.Choice == vote.Abstain }
|
filterFunc := func(_v vote.Vote) bool { return _v.Choice == vote.Abstain }
|
||||||
return filter.Choose(v.Votes(), filterFunc).([]vote.Vote)
|
return filter.Choose(v.Votes(), filterFunc).([]vote.Vote)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -77,23 +77,23 @@ func (q Quorum) IsSatisfied(possibleVotes, totalVotes int) bool {
|
||||||
case Simple:
|
case Simple:
|
||||||
return true
|
return true
|
||||||
case OneFifth:
|
case OneFifth:
|
||||||
return totalVotes * 5 >= possibleVotes
|
return totalVotes*5 >= possibleVotes
|
||||||
case OneQuarter:
|
case OneQuarter:
|
||||||
return totalVotes * 4 >= possibleVotes
|
return totalVotes*4 >= possibleVotes
|
||||||
case OneThird:
|
case OneThird:
|
||||||
return totalVotes * 3 >= possibleVotes
|
return totalVotes*3 >= possibleVotes
|
||||||
case OneHalf:
|
case OneHalf:
|
||||||
return totalVotes * 2 >= possibleVotes
|
return totalVotes*2 >= possibleVotes
|
||||||
case TwoThirds:
|
case TwoThirds:
|
||||||
return totalVotes * 3 >= possibleVotes * 2
|
return totalVotes*3 >= possibleVotes*2
|
||||||
case TwoFifths:
|
case TwoFifths:
|
||||||
return totalVotes * 5 >= possibleVotes * 2
|
return totalVotes*5 >= possibleVotes*2
|
||||||
case ThreeQuarters:
|
case ThreeQuarters:
|
||||||
return totalVotes * 4 >= possibleVotes * 3
|
return totalVotes*4 >= possibleVotes*3
|
||||||
case ThreeFifths:
|
case ThreeFifths:
|
||||||
return totalVotes * 5 >= possibleVotes * 3
|
return totalVotes*5 >= possibleVotes*3
|
||||||
case FourFifths:
|
case FourFifths:
|
||||||
return totalVotes * 5 >= possibleVotes * 4
|
return totalVotes*5 >= possibleVotes*4
|
||||||
case Unanimous:
|
case Unanimous:
|
||||||
return totalVotes >= possibleVotes
|
return totalVotes >= possibleVotes
|
||||||
default:
|
default:
|
||||||
|
|
|
@ -77,23 +77,23 @@ func (t Threshold) IsSatisfied(totalVotes, yesVotes, noVotes int) bool {
|
||||||
case Simple:
|
case Simple:
|
||||||
return yesVotes > noVotes
|
return yesVotes > noVotes
|
||||||
case OneFifth:
|
case OneFifth:
|
||||||
return yesVotes * 5 >= totalVotes
|
return yesVotes*5 >= totalVotes
|
||||||
case OneQuarter:
|
case OneQuarter:
|
||||||
return yesVotes * 4 >= totalVotes
|
return yesVotes*4 >= totalVotes
|
||||||
case OneThird:
|
case OneThird:
|
||||||
return yesVotes * 3 >= totalVotes
|
return yesVotes*3 >= totalVotes
|
||||||
case OneHalf:
|
case OneHalf:
|
||||||
return yesVotes * 2 >= totalVotes
|
return yesVotes*2 >= totalVotes
|
||||||
case TwoThirds:
|
case TwoThirds:
|
||||||
return yesVotes * 3 >= totalVotes * 2
|
return yesVotes*3 >= totalVotes*2
|
||||||
case TwoFifths:
|
case TwoFifths:
|
||||||
return yesVotes * 5 >= totalVotes * 2
|
return yesVotes*5 >= totalVotes*2
|
||||||
case ThreeQuarters:
|
case ThreeQuarters:
|
||||||
return yesVotes * 4 >= totalVotes * 3
|
return yesVotes*4 >= totalVotes*3
|
||||||
case ThreeFifths:
|
case ThreeFifths:
|
||||||
return yesVotes * 5 >= totalVotes * 3
|
return yesVotes*5 >= totalVotes*3
|
||||||
case FourFifths:
|
case FourFifths:
|
||||||
return yesVotes * 5 >= totalVotes * 4
|
return yesVotes*5 >= totalVotes*4
|
||||||
case Unanimous:
|
case Unanimous:
|
||||||
return yesVotes >= totalVotes
|
return yesVotes >= totalVotes
|
||||||
default:
|
default:
|
||||||
|
|
Loading…
Reference in a new issue