reformat code

This commit is contained in:
hdt3213
2021-04-03 20:14:12 +08:00
parent bf913a5aca
commit bcf0cd5e92
54 changed files with 4887 additions and 4896 deletions

View File

@@ -2,11 +2,13 @@
[中文版](https://github.com/HDT3213/godis/blob/master/README_CN.md)
`Godis` is a simple implementation of Redis Server, which intents to provide an example of writing a high concurrent middleware using golang.
`Godis` is a simple implementation of Redis Server, which intents to provide an example of writing a high concurrent
middleware using golang.
Please be advised, NEVER think about using this in production environment.
This repository implemented most features of redis, including 5 data structures, ttl, publish/subscribe, AOF persistence and server side cluster mode.
This repository implemented most features of redis, including 5 data structures, ttl, publish/subscribe, AOF persistence
and server side cluster mode.
If you could read Chinese, you can find more details in [My Blog](https://www.cnblogs.com/Finley/category/1598973.html).
@@ -35,8 +37,7 @@ peers localhost:7379,localhost:7389 // other node in cluster
self localhost:6399 // self address
```
We provide node1.conf and node2.conf for demonstration.
use following command line to start a two-node-cluster:
We provide node1.conf and node2.conf for demonstration. use following command line to start a two-node-cluster:
```bash
CONFIG=node1.conf ./godis-darwin &

View File

@@ -2,8 +2,8 @@ Godis 是一个用 Go 语言实现的 Redis 服务器。本项目旨在为尝试
**请注意:不要在生产环境使用使用此项目**
Godis 实现了 Redis 的大多数功能包括5种数据结构、TTL、发布订阅以及 AOF 持久化。可以在[我的博客](https://www.cnblogs.com/Finley/category/1598973.html)了解更多关于 Godis 的信息。
Godis 实现了 Redis 的大多数功能包括5种数据结构、TTL、发布订阅以及 AOF 持久化。可以在[我的博客](https://www.cnblogs.com/Finley/category/1598973.html)了解更多关于
Godis 的信息。
# 运行 Godis

View File

@@ -37,4 +37,3 @@ func RenameNx(cluster *Cluster, c redis.Connection, args [][]byte) redis.Reply {
}
return cluster.Relay(srcPeer, c, args)
}

View File

@@ -1,9 +1,9 @@
package list
import (
"testing"
"strconv"
"strings"
"testing"
)
func ToString(list *LinkedList) string {

View File

@@ -106,7 +106,6 @@ func (locks *Locks)RLocks(keys ...string) {
}
}
func (locks *Locks) UnLocks(keys ...string) {
indices := locks.toLockIndices(keys, true)
for _, index := range indices {

View File

@@ -6,7 +6,6 @@ const (
maxLevel = 16
)
type Element struct {
Member string
Score float64

View File

@@ -214,7 +214,6 @@ func (sortedSet *SortedSet) RemoveByScore(min *ScoreBorder, max *ScoreBorder)int
return int64(len(removed))
}
/*
* 0-based rank, [start, stop)
*/

View File

@@ -1,8 +1,8 @@
package tcp
import (
"net"
"context"
"net"
)
type HandleFunc func(ctx context.Context, conn net.Conn)

View File

@@ -1,11 +1,11 @@
package files
import (
"mime/multipart"
"io/ioutil"
"path"
"os"
"fmt"
"io/ioutil"
"mime/multipart"
"os"
"path"
)
func GetSize(f multipart.File) (int, error) {

View File

@@ -15,5 +15,3 @@ func (b *AtomicBool)Set(v bool) {
atomic.StoreUint32((*uint32)(b), 0)
}
}

View File

@@ -310,7 +310,6 @@ func (client *Client) handleRead() error {
client.finishRequest(reply)
}
// finish reply
expectedArgsCount = 0
receivedCount = 0

View File

@@ -110,7 +110,6 @@ func (r *IntReply) ToBytes() []byte {
return []byte(":" + strconv.FormatInt(r.Code, 10) + CRLF)
}
/* ---- Error Reply ---- */
type ErrorReply interface {

View File

@@ -5,15 +5,15 @@ package tcp
*/
import (
"net"
"context"
"bufio"
"context"
"github.com/HDT3213/godis/src/lib/logger"
"sync"
"io"
"github.com/HDT3213/godis/src/lib/sync/atomic"
"time"
"github.com/HDT3213/godis/src/lib/sync/wait"
"io"
"net"
"sync"
"time"
)
type EchoHandler struct {
@@ -21,9 +21,8 @@ type EchoHandler struct {
closing atomic.AtomicBool
}
func MakeEchoHandler()(*EchoHandler) {
return &EchoHandler{
}
func MakeEchoHandler() *EchoHandler {
return &EchoHandler{}
}
type Client struct {

View File

@@ -45,7 +45,6 @@ func ListenAndServe(cfg *Config, handler tcp.Handler) {
}
}()
// listen port
logger.Info(fmt.Sprintf("bind: %s, start listening...", cfg.Address))
defer func() {