Files
de61635b81 refactor: move all packages under pkg/ for v5 (#559)
* refactor: move all packages under pkg/ for v5

Move all 13 top-level Go packages into pkg/ for a cleaner repository
structure. All internal import paths updated from
github.com/formancehq/go-libs/v5/<pkg> to
github.com/formancehq/go-libs/v5/pkg/<pkg>.

Also includes cleanup:
- Fix .golangci.yml stale v4 CircuitBreaker path
- Replace deprecated str.Contains with stdlib slices.Contains
- Update TODO(v4) markers to TODO
- Delete stale coverage.txt
- Fix pgtesting timeout not being propagated to docker pool
- Update docs/ARCHITECTURE.md to reflect new structure

Co-Authored-By: Claude Opus 4.6 <[email protected]>

* chore: remove compatibility aliases, unused params, and stub files

- Remove unused type aliases (Authenticator, KeySet) from authnfx
- Remove unused `debug` parameter from S3ModuleFromFlags
- Delete comment-only stub files in messaging/publish/circuit/

Co-Authored-By: Claude Opus 4.6 <[email protected]>

* chore: rename cli.go to flags.go for consistency

Standardize naming across all packages: cli.go -> flags.go
since these files all serve the same purpose (flag definitions).

Co-Authored-By: Claude Opus 4.6 <[email protected]>

* chore: rename

* chore(deps): update all dependencies

Co-Authored-By: Claude Opus 4.6 <[email protected]>

* fix: resolve package name mismatches in generated mocks

Generated mock files had stale package names from before the pkg/ move,
causing import cycles and build failures with --build-tags it.

Co-Authored-By: Claude Opus 4.6 <[email protected]>

---------

Co-authored-by: Claude Opus 4.6 <[email protected]>
2026-03-20 09:17:12 +00:00

93 lines
1.7 KiB
Go

package paginate
import (
"database/sql"
"database/sql/driver"
"encoding/json"
"fmt"
"math/big"
)
type BigInt big.Int
func (i *BigInt) MarshalJSON() ([]byte, error) {
return json.Marshal(i.ToMathBig())
}
func (i *BigInt) UnmarshalJSON(bytes []byte) error {
v, err := i.FromString(string(bytes))
if err != nil {
return err
}
*i = *v
return nil
}
func NewInt() *BigInt {
return new(BigInt)
}
func newBigint(x *big.Int) *BigInt {
return (*BigInt)(x)
}
// same as NewBigint()
func FromMathBig(x *big.Int) *BigInt {
return (*BigInt)(x)
}
func FromInt64(x int64) *BigInt {
return FromMathBig(big.NewInt(x))
}
func (i *BigInt) FromString(x string) (*BigInt, error) {
if x == "" {
return FromInt64(0), nil
}
a := big.NewInt(0)
b, ok := a.SetString(x, 10)
if !ok {
return nil, fmt.Errorf("cannot create Int from string")
}
return newBigint(b), nil
}
func (b *BigInt) Value() (driver.Value, error) {
return (*big.Int)(b).String(), nil
}
func (b *BigInt) Set(v *BigInt) *BigInt {
return (*BigInt)((*big.Int)(b).Set((*big.Int)(v)))
}
func (b *BigInt) Sub(x *BigInt, y *BigInt) *BigInt {
return (*BigInt)((*big.Int)(b).Sub((*big.Int)(x), (*big.Int)(y)))
}
func (b *BigInt) Scan(value interface{}) error {
var i sql.NullString
if err := i.Scan(value); err != nil {
return err
}
if _, ok := (*big.Int)(b).SetString(i.String, 10); ok {
return nil
}
return fmt.Errorf("Error converting type %T into Bigint", value)
}
func (b *BigInt) ToMathBig() *big.Int {
return (*big.Int)(b)
}
func (i *BigInt) Cmp(bottom *BigInt) int {
return (*big.Int)(i).Cmp((*big.Int)(bottom))
}
var _ json.Unmarshaler = (*BigInt)(nil)
var _ json.Marshaler = (*BigInt)(nil)