Created
April 15, 2020 19:26
-
-
Save akerl-unpriv/d94d02cb21a333776d4ebaf2a24f8849 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"bufio" | |
"fmt" | |
"os" | |
"github.com/ktr0731/go-fuzzyfinder" | |
) | |
func getSelection() error { | |
lines := make([]bool, 5) | |
handler := func(i int) string { | |
return fmt.Sprintf("Test entry %d", i) | |
} | |
_, err := fuzzyfinder.Find( | |
lines, | |
handler, | |
) | |
return err | |
} | |
func getText() error { | |
reader := bufio.NewReader(os.Stdin) | |
fmt.Fprint(os.Stderr, "Enter string: ") | |
entry, err := reader.ReadString('\n') | |
if err != nil { | |
return err | |
} | |
fmt.Printf("I captured: %s (len %d)", entry, len(entry)) | |
return nil | |
} | |
func main() { | |
if err := getSelection(); err != nil { | |
panic(err) | |
} | |
if err := getText(); err != nil { | |
panic(err) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment