-
Notifications
You must be signed in to change notification settings - Fork 0
epic(generics): use Go1.18 type parameters #66
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
GregoryAlbouy
wants to merge
19
commits into
go1.18-generics-experimentation-base
Choose a base branch
from
go1.18-generics-experimentation
base: go1.18-generics-experimentation-base
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
epic(generics): use Go1.18 type parameters #66
GregoryAlbouy
wants to merge
19
commits into
go1.18-generics-experimentation-base
from
go1.18-generics-experimentation
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
* Use go1.18
- Declare go 1.18 in go.mod
- Update make commands
* Declare generic checker types
* Type checker providers using Checker[T] interface
* Update checker providers interfaces
- Disable code generation for providers interfaces
- Update providers interfaces manually
* Update checker providers unit tests
* Update package check examples
* Update package checkconv
- Type checkconv.Assert using check.Checker[T] interface
- Type checkconv.Cast using check.Checker[T] interface
* Update testx runners
- Add type parameters to ValueRunner
- Use new type check.Checker[T]
- Update tests and examples
* Update temporary CI config
- Disable jobs: gen, lint
- Disable test coverage
- Add setup step: Install gotip
* Replace all occurrences of interface{} -> any
b737d9c to
5426b7b
Compare
* Remove code generation directives and templates * Remove typed checkers declarations * Update remaining usages of typed checkers
* Implement check.Wrap, check.WrapMany * Create temp package slices * Write unit tests for check.Wrap, WrapMany * Replace all checkconv usages with check.Wrap * Delete package checkconv * Use package drykit-go/slicex - Remove local package internal/slices - Install and use github.com/drykit-go/slicex v0.0.1
* Implement generic numberCheckerProvider[T Numeric] * Update interfaces accordingly * Write unit tests for numberCheckerProvider * Delete previous numeric checker implementations - intCheckerProvider - float64CheckerProvider
* Delete go generate directive for typed checkers * Remove kind "types" from cmd * Remove gen.Types * Remove template: assert.gotmpl * Update contributing guidelines
* Pre-compute numeric vars for numberCheckerProvider * Re-enable code generation for providers interfaces * Fix numberCheckerProvider interface generation * Run make gen
* Delete obsolete example * Update readmes * Remove last mentions of <Type>Checkers
* Remove mention to checkconv in readme * Fix impossible example
* Type TableRunner with generics * Remove testx.ExpNil * Update unit tests to new Case.Exp behaviour * Reorganize unit tests
* Remove mentions to checkconv and uncovered types * Run make gen
* Exclude lint errors due to unsupported 1.18 syntax * Restore CI job: lint * Use gotip in make command: test-cov * Restore CI step: coverage * Restore CI job: gen * Use golangci-lint v1.43.0 in CI
* Remove interfaces generation logics * Run make gen * Update package gen namings and docs * Fix docparser.ParseDocLines docs * Export checker providers structs * Update providers gen * Run make gen * Refactor some var names generation
Codecov Report
@@ Coverage Diff @@
## go1.18-generics-experimentation-base #66 +/- ##
========================================================================
- Coverage 95.89% 94.65% -1.25%
========================================================================
Files 33 32 -1
Lines 1290 1159 -131
========================================================================
- Hits 1237 1097 -140
- Misses 40 46 +6
- Partials 13 16 +3
Continue to review full report at Codecov.
|
* Use fixed gotip version * Remove duplicate gotip download command * Fix CI: add confirmation user prompt * Add '|| true' to gotip download command
* Use generics in MapCheckerProvider implementation * Update code gen and template manually * Run make gen * Update Map unit tests * Update Bytes.AsMap - Change parameter type Checker[any] -> Cheker[map[string]any] - Update unit tests for Bytes - Run make gen
* Type SliceCheckerProvider with generics * Update var gen * Run make gen * Update unit tests * Fix Map().CheckValues explain output
* Update var gen * Run make gen * Type ValueCheckerProvider with generics * Update unit tests * Exclude lint rule with false positive
* Create internal package checktypes - Avoid cyclic deps * Create package internal/providers - Copy providers impl and tests into internal/providers * Update code gen - Move check/gen.go -> internal/providers/gen.go - Require output filepath argument (-o) - Adapt providers vars generation logics * Run make gen * Remove providers files in package check * Fix check.Wrap inference issues
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
An experimentation branch to see where would lead the usage of generics in
testxChanges
So far:
All
<Type>Checkerinterfaces removed for a singleChecker[T any]insteadHalf of the code generation logics removed
Whole package
checkconvremoved for a single functioncheck.Wrapinstead (no such thing as "known checker type" anymore)➡️ More than 20% of the codebase removed
Caveats:
numberCheckerProvider, see b101eadFix numberCheckerProvider interface generation)golangci-lint(CI/lint)go-acc(CI/coverage)goimports(formats generated file)Screenshots
Linked issue