最近看到github上大神用golang实现的Redis,那我最近也有类似的需求,我尝试着看大神的代码,然后实现出来,在这里也跟大家推荐一下,源码地址是https://github.com/HDT3213/godis
func main() {
config.SetupConfig("redis.conf")
}
package config
import (
"bufio"
"fmt"
"log"
"os"
"reflect"
"strconv"
"strings"
)
type PropertyHolder struct {
Bind string `cfg:"bind"`
Port int `cfg:"port"`
AppendOnly bool `cfg:"appendOnly"`
AppendFileName string `cfg:"appendFileName"`
MaxClients int `cfg:"maxClients"`
Peers []string `cfg:"peers"`
Self string `cfg:"self"`
}
var Properties *PropertyHolder
func init() {
// 默认配置
Properties = &PropertyHolder{
Bind: "127.0.0.1",
Port: 6379,
AppendOnly: false,
}
}