Documentation ¶
Index ¶
Constants ¶
const BitsPerWord uint = 12
BitsPerWord is the number of bits of information represented by each word in the wordlist.
Variables ¶
var WordList []string
WordList is the mnemonic encoding wordlist in alphabetical sorted order.
var WordMap = make(map[string]uint16)
WordMap is a mapping of words to their indices in the wordlist.
Functions ¶
This section is empty.
Types ¶
type SearchResult ¶
type SearchResult struct { // ExactMatch is true if the input query is a valid word in the wordlist. // Indicates that the first element of the Suffixes field will be the empty string. // // Note that finding an exact match does not necessarily mean it is the only // possible word. Some words are prefixes of others ("car" and "cargo"). ExactMatch bool // Suffixes is a set of suffix strings which can be appended to the original // input query to make it a valid word in the wordlist. Suffixes []string }
SearchResult is returned by the Search function. It indicates the suffixes which could complete the input query to make it a valid word in the wordlist, including the empty string if an exact match was found.
func Search ¶
func Search(query string) *SearchResult
Search runs a binary search on the wordlist to find any words which match the given input query string. This is useful for autocomplete and error correction.
The input query must be in lower case to return any results. If the query is empty, returns a SearchResult with an empty suffixes list.