MCPcopy Create free account
hub / github.com/ajitpratap0/GoSQLX / Example_typoDetection

Function Example_typoDetection

pkg/errors/example_test.go:40–66  ·  view source on GitHub ↗

Example_typoDetection demonstrates automatic typo detection

()

Source from the content-addressed store, hash-verified

38
39// Example_typoDetection demonstrates automatic typo detection
40func Example_typoDetection() {
41 // Common SQL keyword typos are automatically detected
42 // Using a slice to maintain predictable order
43 typos := []struct {
44 typo string
45 correct string
46 }{
47 {"FORM", "FROM"},
48 {"JION", "JOIN"},
49 {"SELCT", "SELECT"},
50 {"UPDTE", "UPDATE"},
51 {"WAHER", "WHERE"},
52 }
53
54 for _, t := range typos {
55 suggestion := errors.SuggestKeyword(t.typo)
56 if suggestion == t.correct {
57 fmt.Printf("%s → %s ✓\n", t.typo, suggestion)
58 }
59 }
60 // Output:
61 // FORM → FROM ✓
62 // JION → JOIN ✓
63 // SELCT → SELECT ✓
64 // UPDTE → UPDATE ✓
65 // WAHER → WHERE ✓
66}
67
68// Example_errorCodes demonstrates programmatic error handling
69func Example_errorCodes() {

Callers

nothing calls this directly

Calls 1

SuggestKeywordFunction · 0.92

Tested by

no test coverage detected