refactor: replace gperr with standard errors package and simplify string parsing

- Replace gperr.Error return types with standard error across test files
- Replace gperr.New with errors.New in validation and serialization tests
- Update API documentation in README files to use error instead of gperr.Error
- Simplify string parsing using strings.Cut in docker/label.go
- Update benchmarks to use NewTestEntrypoint and remove task package dependency
This commit is contained in:
yusing
2026-02-10 16:59:19 +08:00
parent a0d0ad0958
commit 1579f490c0
11 changed files with 45 additions and 69 deletions

View File

@@ -1,24 +1,23 @@
package serialization
import (
"errors"
"reflect"
"testing"
gperr "github.com/yusing/goutils/errs"
)
// Test cases for when *T implements CustomValidator but T is passed in
type CustomValidatingInt int
func (c *CustomValidatingInt) Validate() gperr.Error {
func (c *CustomValidatingInt) Validate() error {
if c == nil {
return gperr.New("pointer int cannot be nil")
return errors.New("pointer int cannot be nil")
}
if *c <= 0 {
return gperr.New("int must be positive")
return errors.New("int must be positive")
}
if *c > 100 {
return gperr.New("int must be <= 100")
return errors.New("int must be <= 100")
}
return nil
}
@@ -26,12 +25,12 @@ func (c *CustomValidatingInt) Validate() gperr.Error {
// Test cases for when T implements CustomValidator but *T is passed in
type CustomValidatingFloat float64
func (c CustomValidatingFloat) Validate() gperr.Error {
func (c CustomValidatingFloat) Validate() error {
if c < 0 {
return gperr.New("float must be non-negative")
return errors.New("float must be non-negative")
}
if c > 1000 {
return gperr.New("float must be <= 1000")
return errors.New("float must be <= 1000")
}
return nil
}