Skip to content

Instantly share code, notes, and snippets.

@akerl-unpriv
Created April 15, 2020 19:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save akerl-unpriv/d94d02cb21a333776d4ebaf2a24f8849 to your computer and use it in GitHub Desktop.
Save akerl-unpriv/d94d02cb21a333776d4ebaf2a24f8849 to your computer and use it in GitHub Desktop.
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