Skip to content

Commit 23e9e68

Browse files
rwinkhartpldubouilh
authored andcommitted
Replace if-else chain in rpc function with switch statement
1 parent 7644c9f commit 23e9e68

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

gossa.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -231,11 +231,12 @@ func rpc(w http.ResponseWriter, r *http.Request) {
231231
check(err)
232232
json.Unmarshal(bodyBytes, &rpc)
233233

234-
if rpc.Call == "mkdirp" {
234+
switch rpc.Call {
235+
case "mkdirp":
235236
err = os.MkdirAll(enforcePath(rpc.Args[0]), os.ModePerm)
236-
} else if rpc.Call == "mv" {
237+
case "mv":
237238
err = os.Rename(enforcePath(rpc.Args[0]), enforcePath(rpc.Args[1]))
238-
} else if rpc.Call == "rm" {
239+
case "rm":
239240
err = os.RemoveAll(enforcePath(rpc.Args[0]))
240241
}
241242

0 commit comments

Comments
 (0)