Start using go mod
This commit is contained in:
parent
7f7436cf62
commit
e9d90a12f7
|
@ -5,13 +5,7 @@ This is the core code of the current release of
|
|||
|
||||
## Dependencies
|
||||
|
||||
- [Go](https://golang.org) 1.10+, Go 1.14 or later recommended.
|
||||
- [bbolt](https://github.com/etcd-io/bbolt)
|
||||
- `go get go.etcd.io/bbolt`
|
||||
- [httprouter](https://github.com/julienschmidt/httprouter)
|
||||
- `go get github.com/julienschmidt/httprouter`
|
||||
- [yaml](https://gopkg.in/yaml.v2)
|
||||
- `go get gopkg.in/yaml.v2`
|
||||
[Go](https://golang.org) 1.13+
|
||||
|
||||
## Configuration
|
||||
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
module github.com/luk3yx/lurkcoin-core
|
||||
|
||||
go 1.13
|
||||
|
||||
require (
|
||||
github.com/julienschmidt/httprouter v1.3.0
|
||||
go.etcd.io/bbolt v1.3.5
|
||||
gopkg.in/yaml.v2 v2.4.0
|
||||
)
|
|
@ -0,0 +1,9 @@
|
|||
github.com/julienschmidt/httprouter v1.3.0 h1:U0609e9tgbseu3rBINet9P48AI/D3oJs4dN7jwJOQ1U=
|
||||
github.com/julienschmidt/httprouter v1.3.0/go.mod h1:JR6WtHb+2LUe8TCKY3cZOxFyyO8IZAc4RVcycCCAKdM=
|
||||
go.etcd.io/bbolt v1.3.5 h1:XAzx9gjCb0Rxj7EoqcClPD1d5ZBxZJk0jbuoPHenBt0=
|
||||
go.etcd.io/bbolt v1.3.5/go.mod h1:G5EMThwa9y8QZGBClrRx5EY+Yw9kAhnjy3bSjsnlVTQ=
|
||||
golang.org/x/sys v0.0.0-20200202164722-d101bd2416d5/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
|
||||
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
|
|
@ -22,11 +22,11 @@ import (
|
|||
"crypto/sha512"
|
||||
"encoding/hex"
|
||||
"github.com/julienschmidt/httprouter"
|
||||
"github.com/luk3yx/lurkcoin-core/lurkcoin"
|
||||
"html"
|
||||
"html/template"
|
||||
"io"
|
||||
"log"
|
||||
"lurkcoin"
|
||||
"net/http"
|
||||
"regexp"
|
||||
"strings"
|
||||
|
@ -327,8 +327,8 @@ type adminPagesSummary struct {
|
|||
}
|
||||
|
||||
func parseNumbers(n1, n2 string) (lurkcoin.Currency, lurkcoin.Currency, bool) {
|
||||
n1 = strings.Replace(n1, ",", "", -1)
|
||||
n2 = strings.Replace(n2, ",", "", -1)
|
||||
n1 = strings.ReplaceAll(n1, ",", "")
|
||||
n2 = strings.ReplaceAll(n2, ",", "")
|
||||
|
||||
var res1, res2 lurkcoin.Currency
|
||||
var err error
|
||||
|
|
|
@ -20,11 +20,11 @@ package api
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/luk3yx/lurkcoin-core/lurkcoin"
|
||||
"github.com/luk3yx/lurkcoin-core/lurkcoin/databases"
|
||||
"gopkg.in/yaml.v2"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"lurkcoin"
|
||||
"lurkcoin/databases"
|
||||
"net"
|
||||
"net/http"
|
||||
"os"
|
||||
|
|
|
@ -22,8 +22,8 @@ import (
|
|||
"encoding/json"
|
||||
"errors"
|
||||
"github.com/julienschmidt/httprouter"
|
||||
"github.com/luk3yx/lurkcoin-core/lurkcoin"
|
||||
"io"
|
||||
"lurkcoin"
|
||||
"net/http"
|
||||
"strings"
|
||||
)
|
||||
|
|
|
@ -22,8 +22,8 @@ package api
|
|||
|
||||
import (
|
||||
"github.com/julienschmidt/httprouter"
|
||||
"github.com/luk3yx/lurkcoin-core/lurkcoin"
|
||||
"log"
|
||||
"lurkcoin"
|
||||
)
|
||||
|
||||
func addV2API(_ *httprouter.Router, _ lurkcoin.Database, _ string) {
|
||||
|
|
|
@ -28,7 +28,7 @@ import (
|
|||
"errors"
|
||||
"fmt"
|
||||
"github.com/julienschmidt/httprouter"
|
||||
"lurkcoin"
|
||||
"github.com/luk3yx/lurkcoin-core/lurkcoin"
|
||||
"math/big"
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
@ -253,7 +253,7 @@ func addV2API(router *httprouter.Router, db lurkcoin.Database,
|
|||
return exc, nil
|
||||
}
|
||||
s := func(n string) string {
|
||||
return strings.Replace(n, "|", "/", -1)
|
||||
return strings.ReplaceAll(n, "|", "/")
|
||||
}
|
||||
transaction := transactions[0]
|
||||
// To support fragile clients (such as versions of the lurkcoin
|
||||
|
@ -261,7 +261,7 @@ func addV2API(router *httprouter.Router, db lurkcoin.Database,
|
|||
return fmt.Sprintf("%g|%d|%s|%s|%s",
|
||||
exc,
|
||||
transaction.GetLegacyID(),
|
||||
s(strings.Replace(transaction.Target, "¤", "_", -1)),
|
||||
s(strings.ReplaceAll(transaction.Target, "¤", "_")),
|
||||
transaction.ReceivedAmount.RawString(),
|
||||
s(transaction.String()),
|
||||
), nil
|
||||
|
@ -270,7 +270,7 @@ func addV2API(router *httprouter.Router, db lurkcoin.Database,
|
|||
for i, transaction := range transactions {
|
||||
res[i] = [4]interface{}{
|
||||
transaction.GetLegacyID(),
|
||||
strings.Replace(transaction.Target, "¤", "_", -1),
|
||||
strings.ReplaceAll(transaction.Target, "¤", "_"),
|
||||
transaction.ReceivedAmount,
|
||||
transaction.String(),
|
||||
}
|
||||
|
|
|
@ -25,7 +25,7 @@ import (
|
|||
"encoding/json"
|
||||
"errors"
|
||||
"github.com/julienschmidt/httprouter"
|
||||
"lurkcoin"
|
||||
"github.com/luk3yx/lurkcoin-core/lurkcoin"
|
||||
"net/http"
|
||||
"strings"
|
||||
)
|
||||
|
|
|
@ -239,7 +239,7 @@ func CurrencyFromFloat64(num float64) Currency {
|
|||
|
||||
func CurrencyFromString(num string) Currency {
|
||||
var res Currency
|
||||
if res.setString(strings.Replace(num, "_", "", -1)) {
|
||||
if res.setString(strings.ReplaceAll(num, "_", "")) {
|
||||
return res
|
||||
} else {
|
||||
return Currency{i0}
|
||||
|
@ -248,7 +248,7 @@ func CurrencyFromString(num string) Currency {
|
|||
|
||||
func ParseCurrency(num string) (Currency, error) {
|
||||
var res Currency
|
||||
if res.setString(strings.Replace(num, "_", "", -1)) {
|
||||
if res.setString(strings.ReplaceAll(num, "_", "")) {
|
||||
return res, nil
|
||||
} else {
|
||||
return Currency{i0}, errors.New("ERR_INVALIDAMOUNT")
|
||||
|
|
|
@ -25,7 +25,7 @@ import (
|
|||
"bytes"
|
||||
"encoding/gob"
|
||||
"errors"
|
||||
"lurkcoin"
|
||||
"github.com/luk3yx/lurkcoin-core/lurkcoin"
|
||||
|
||||
bolt "go.etcd.io/bbolt"
|
||||
)
|
||||
|
|
|
@ -22,8 +22,8 @@ package databases
|
|||
|
||||
import (
|
||||
"encoding/json"
|
||||
"github.com/luk3yx/lurkcoin-core/lurkcoin"
|
||||
"io/ioutil"
|
||||
"lurkcoin"
|
||||
"os"
|
||||
"path"
|
||||
"sync"
|
||||
|
|
|
@ -20,7 +20,7 @@ package databases
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"lurkcoin"
|
||||
"github.com/luk3yx/lurkcoin-core/lurkcoin"
|
||||
"sort"
|
||||
"strings"
|
||||
"sync"
|
||||
|
|
|
@ -59,7 +59,7 @@ var invalid_uid = regexp.MustCompile(`[^a-z0-9\_]`)
|
|||
|
||||
func HomogeniseUsername(username string) string {
|
||||
username = strings.ToLower(username)
|
||||
username = strings.Replace(username, " ", "", -1)
|
||||
username = strings.ReplaceAll(username, " ", "")
|
||||
return invalid_uid.ReplaceAllLiteralString(username, "_")
|
||||
}
|
||||
|
||||
|
|
2
main.go
2
main.go
|
@ -20,8 +20,8 @@ package main
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/luk3yx/lurkcoin-core/lurkcoin/api"
|
||||
"log"
|
||||
"lurkcoin/api"
|
||||
"os"
|
||||
)
|
||||
|
||||
|
|
|
@ -20,9 +20,9 @@ package main
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/luk3yx/lurkcoin-core/lurkcoin"
|
||||
"github.com/luk3yx/lurkcoin-core/lurkcoin/api"
|
||||
"log"
|
||||
"lurkcoin"
|
||||
"lurkcoin/api"
|
||||
"os"
|
||||
)
|
||||
|
||||
|
|
Loading…
Reference in New Issue