@@ -17,7 +17,7 @@ import (
1717 cli "gopkg.in/urfave/cli.v2"
1818)
1919
20- // TODO better suggest
20+ // TODO better suggest, suggest based on hash key and range key
2121var tableNameSuggestions []prompt.Suggest
2222
2323// Key bindings, reserved, might use them oneday
@@ -71,16 +71,13 @@ func executor(in string) {
7171
7272 ctx , cancel := context .WithCancel (context .Background ())
7373 sigCh := make (chan os.Signal , 1 )
74- signal .Notify (sigCh , os .Interrupt )
74+ signal .Notify (sigCh , os .Interrupt ) // sigCh only listens to os.Interrupt
7575 // Listen to the os interrupt signal which is ctrl+c
7676 // when ctrl+c is pressed, cancel current query
77- // killSigCh for notify this goroutine to terminate, otherwise it will keep listening
78- killSigCh := make (chan struct {}, 1 )
7977 go func () {
8078 select {
8179 case <- sigCh :
8280 cancel ()
83- case <- killSigCh :
8481 return
8582 }
8683 }()
@@ -93,13 +90,10 @@ func executor(in string) {
9390 // so that new prompts won't popup
9491 select {
9592 case <- ctx .Done ():
96- killSigCh <- struct {}{}
9793 return
9894 case r := <- resultCh :
99- killSigCh <- struct {}{}
10095 fmt .Println (r )
10196 case e := <- errCh :
102- killSigCh <- struct {}{}
10397 fmt .Println (e )
10498 }
10599 }
@@ -179,6 +173,7 @@ func completer(d prompt.Document) []prompt.Suggest {
179173
180174func main () {
181175 // grmon.Start()
176+ defer recover ()
182177 var accessKeyID string
183178 var secretAccessKey string
184179 var region string
@@ -235,5 +230,4 @@ func main() {
235230 if err := app .Run (os .Args ); err != nil {
236231 fmt .Println (err .Error ())
237232 }
238- defer recover ()
239233}
0 commit comments