From 82ed1e831e6c80f75b2a975c9740006451504396 Mon Sep 17 00:00:00 2001 From: lion Date: Tue, 21 Jun 2022 18:02:40 +0800 Subject: [PATCH] break for the undefine option --- binding/golang/main.go | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/binding/golang/main.go b/binding/golang/main.go index 3732f8b..8827be2 100644 --- a/binding/golang/main.go +++ b/binding/golang/main.go @@ -40,17 +40,20 @@ func testSearch() { continue } - var eIdx = strings.Index(r, "=") - if eIdx < 0 { + var sIdx = strings.Index(r, "=") + if sIdx < 0 { fmt.Printf("missing = for args pair '%s'\n", r) return } - switch r[2:eIdx] { + switch r[2:sIdx] { case "db": - dbFile = r[eIdx+1:] + dbFile = r[sIdx+1:] case "cache-policy": - cachePolicy = r[eIdx+1:] + cachePolicy = r[sIdx+1:] + default: + fmt.Printf("undefined option `%s`\n", r) + return } } @@ -122,19 +125,22 @@ func testBench() { continue } - var eIdx = strings.Index(r, "=") - if eIdx < 0 { + var sIdx = strings.Index(r, "=") + if sIdx < 0 { fmt.Printf("missing = for args pair '%s'\n", r) return } - switch r[2:eIdx] { + switch r[2:sIdx] { case "db": - dbFile = r[eIdx+1:] + dbFile = r[sIdx+1:] case "src": - srcFile = r[eIdx+1:] + srcFile = r[sIdx+1:] case "cache-policy": - cachePolicy = r[eIdx+1:] + cachePolicy = r[sIdx+1:] + default: + fmt.Printf("undefined option `%s`\n", r) + return } }