Summary
Add runnable godoc examples to all core packages to improve discoverability and usability on pkg.go.dev.
Problem
Missing runnable examples in package docs - users can't see working code on pkg.go.dev.
Action Items
-
Add godoc examples to core packages:
pkg/sql/tokenizer:
Example_Tokenize() - Basic tokenization
Example_TokenizeWithPool() - Pool usage
Example_ErrorHandling() - Error handling
pkg/sql/parser:
Example_Parse() - Basic parsing
Example_ParseError() - Error recovery
Example_ComplexQuery() - Window functions, CTEs
pkg/sql/ast:
Example_Visitor() - AST traversal
Example_Walk() - Tree walking
Example_NodeAccess() - Accessing node data
pkg/gosqlx:
Example_Parse() - Simple API
Example_Validate() - Validation
Example_Format() - Formatting
-
Add examples for each major public function
-
Ensure all examples are runnable with go test
-
Add Output: comments to show expected results
Acceptance Criteria
Technical Details
Priority: Medium
Effort: Medium (20h)
Phase: Phase 3 - UX & Documentation
Dependencies: None
Example Template
func Example_basicParsing() {
ast, err := gosqlx.Parse("SELECT * FROM users")
if err != nil {
log.Fatal(err)
}
fmt.Printf("Parsed %d statements\n", len(ast.Statements))
// Output: Parsed 1 statements
}
Summary
Add runnable godoc examples to all core packages to improve discoverability and usability on pkg.go.dev.
Problem
Missing runnable examples in package docs - users can't see working code on pkg.go.dev.
Action Items
Add godoc examples to core packages:
pkg/sql/tokenizer:Example_Tokenize()- Basic tokenizationExample_TokenizeWithPool()- Pool usageExample_ErrorHandling()- Error handlingpkg/sql/parser:Example_Parse()- Basic parsingExample_ParseError()- Error recoveryExample_ComplexQuery()- Window functions, CTEspkg/sql/ast:Example_Visitor()- AST traversalExample_Walk()- Tree walkingExample_NodeAccess()- Accessing node datapkg/gosqlx:Example_Parse()- Simple APIExample_Validate()- ValidationExample_Format()- FormattingAdd examples for each major public function
Ensure all examples are runnable with
go testAdd Output: comments to show expected results
Acceptance Criteria
go test -run Example)Technical Details
Priority: Medium
Effort: Medium (20h)
Phase: Phase 3 - UX & Documentation
Dependencies: None
Example Template