v1.8.0 - Full Go Generics Support
π Full Go Generics Support
This release adds complete support for Go generics (type parameters), enabling gotests to generate tests for generic functions and methods on generic types.
β¨ Key Features
-
π§ Generic Functions: Generate tests for functions with type parameters
func FindFirst[T comparable](slice []T, target T) (int, error)
-
ποΈ Generic Types: Support for methods on generic types
type Set[T comparable] struct { ... } func (s *Set[T]) Add(v T)
-
π― All Constraint Types:
any,comparable, union types (int64 | float64), approximation (~int) -
π§ Smart Type Mapping: Intelligent defaults for type instantiation
anyβintcomparableβstring- Union types β first option
- Approximation β underlying type
-
π Multiple Type Parameters: Handles functions like
Pair[T, U any]
π Test Coverage
- β 97.5% main package coverage
- β 83.5% overall project coverage
- β 100% coverage on all new parser functions
- β 8 comprehensive generic test patterns
π§ Technical Improvements
Parser Enhancements:
- New
parseTypeDecls()extracts type parameters from type declarations - New
parseTypeParams()parses AST field lists - New
extractBaseTypeName()handles receiver types
Template Functions:
TypeArgs- generates concrete type arguments for callsFieldType- substitutes type parameters in field declarationsReceiverType- substitutes type parameters in receiver instantiations
Model Updates:
- New
TypeParamstruct - Added
TypeParamsfield toFunction - Helper methods:
IsGeneric(),HasGenericReceiver()
π Documentation
Added comprehensive "Go Generics Support" section to README with:
- Example: Generic function test generation
- Example: Methods on generic types
- Type constraint mapping reference
π Fixes
Closes #165
π¦ Installation
go install github.com/cweill/gotests/gotests@v1.8.0π Credits
π€ Developed with assistance from Claude Code
Full Changelog: v1.7.0...v1.8.0