jackc / jackc/pgx

Custom type

Open
#1,913 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
Go
Stars
14.3k
Forks
1.1k
Avg merge
6d 9h
Merged PRs (30d)
11

Description

Hello,

I've adapted the shopspring decimal.Decimal type for uint256.Int (https://github.com/holiman/uint256).

Even though uint256.Int types can be used as non-pointer types, they are usually used as pointer types, so in TryWrapNumericScanPlan() I'm handling both *uint256.Int and **uint256.Int. I'm wondering however where the proper place to allocate a fresh uint256.Int for the **uint256.Int case would be.

I'm currently doing it in the scan plan Scan() method:

```
func (plan *wrapUint256ScanPlan) Scan(src []byte, dst interface{}) error {
switch dst := dst.(type) {
case *uint256.Int:
return plan.next.Scan(src, (*Uint256)(dst))
case **uint256.Int:
*dst = new(uint256.Int)
return plan.next.Scan(src, (*Uint256)(*dst))
default:
panic("")
}
}
```

This works fine, but I'm wondering if this is really the proper spot.

Thanks for any advice!

Contributor guide

Open the contributing guide

Research direction

Start by reading TryWrapNumericScanPlan() and the shown wrapUint256ScanPlan.Scan() implementation, focusing on handling *uint256.Int and **uint256.Int. Done means determining the appropriate allocation point for **uint256.Int; the payload names no project file or test to run.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
database
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.