File tree Expand file tree Collapse file tree 1 file changed +7
-22
lines changed Expand file tree Collapse file tree 1 file changed +7
-22
lines changed Original file line number Diff line number Diff line change @@ -91,29 +91,14 @@ func (s *Server) handleConnection(conn net.Conn) {
91
91
query = strings .Trim (query , " " )
92
92
query = strings .ReplaceAll (query , "\n " , "" )
93
93
tokens := strings .Split (query , " " )
94
- querytype := tokens [0 ]
95
94
var res string
96
- switch strings .ToUpper (querytype ) {
97
- case "SET" :
98
- if (len (tokens )) != 3 {
99
- res = invalidquery
100
- } else {
101
-
102
- res = s .db .SetValue (tokens [1 ], tokens [2 ])
103
- }
104
- case "GET" :
105
- if len (tokens ) != 2 {
106
- res = invalidquery
107
- } else {
108
-
109
- res = s .db .GetValue (tokens [1 ])
110
- }
111
- case "DEL" :
112
- if len (tokens ) != 2 {
113
- res = invalidquery
114
- } else {
115
- res = s .db .DeleteValue (tokens [1 ])
116
- }
95
+ switch {
96
+ case tokens [0 ] == "set" && len (tokens ) == 3 :
97
+ res = s .db .SetValue (tokens [1 ], tokens [2 ])
98
+ case tokens [0 ] == "get" && len (tokens ) == 2 :
99
+ res = s .db .GetValue (tokens [1 ])
100
+ case tokens [0 ] == "del" && len (tokens ) == 2 :
101
+ res = s .db .DeleteValue (tokens [1 ])
117
102
default :
118
103
res = invalidquery
119
104
}
You can’t perform that action at this time.
0 commit comments