Example_typoDetection demonstrates automatic typo detection
()
| 38 | |
| 39 | // Example_typoDetection demonstrates automatic typo detection |
| 40 | func 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 |
| 69 | func Example_errorCodes() { |
nothing calls this directly
no test coverage detected