Skip to content

Commit dd81f81

Browse files
authored
Merge pull request #2369 from zeghong/go-doc-links
Add support for Go doc comment links
2 parents 839acba + fc289cb commit dd81f81

35 files changed

+192
-92
lines changed

pgtype/array.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -374,8 +374,8 @@ func quoteArrayElementIfNeeded(src string) string {
374374
return src
375375
}
376376

377-
// Array represents a PostgreSQL array for T. It implements the ArrayGetter and ArraySetter interfaces. It preserves
378-
// PostgreSQL dimensions and custom lower bounds. Use FlatArray if these are not needed.
377+
// Array represents a PostgreSQL array for T. It implements the [ArrayGetter] and [ArraySetter] interfaces. It preserves
378+
// PostgreSQL dimensions and custom lower bounds. Use [FlatArray] if these are not needed.
379379
type Array[T any] struct {
380380
Elements []T
381381
Dims []ArrayDimension
@@ -419,8 +419,8 @@ func (a Array[T]) ScanIndexType() any {
419419
return new(T)
420420
}
421421

422-
// FlatArray implements the ArrayGetter and ArraySetter interfaces for any slice of T. It ignores PostgreSQL dimensions
423-
// and custom lower bounds. Use Array to preserve these.
422+
// FlatArray implements the [ArrayGetter] and [ArraySetter] interfaces for any slice of T. It ignores PostgreSQL dimensions
423+
// and custom lower bounds. Use [Array] to preserve these.
424424
type FlatArray[T any] []T
425425

426426
func (a FlatArray[T]) Dimensions() []ArrayDimension {

pgtype/bits.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,16 +23,18 @@ type Bits struct {
2323
Valid bool
2424
}
2525

26+
// ScanBits implements the [BitsScanner] interface.
2627
func (b *Bits) ScanBits(v Bits) error {
2728
*b = v
2829
return nil
2930
}
3031

32+
// BitsValue implements the [BitsValuer] interface.
3133
func (b Bits) BitsValue() (Bits, error) {
3234
return b, nil
3335
}
3436

35-
// Scan implements the database/sql Scanner interface.
37+
// Scan implements the [database/sql.Scanner] interface.
3638
func (dst *Bits) Scan(src any) error {
3739
if src == nil {
3840
*dst = Bits{}
@@ -47,7 +49,7 @@ func (dst *Bits) Scan(src any) error {
4749
return fmt.Errorf("cannot scan %T", src)
4850
}
4951

50-
// Value implements the database/sql/driver Valuer interface.
52+
// Value implements the [database/sql/driver.Valuer] interface.
5153
func (src Bits) Value() (driver.Value, error) {
5254
if !src.Valid {
5355
return nil, nil

pgtype/bool.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,18 @@ type Bool struct {
2222
Valid bool
2323
}
2424

25+
// ScanBool implements the [BoolScanner] interface.
2526
func (b *Bool) ScanBool(v Bool) error {
2627
*b = v
2728
return nil
2829
}
2930

31+
// BoolValue implements the [BoolValuer] interface.
3032
func (b Bool) BoolValue() (Bool, error) {
3133
return b, nil
3234
}
3335

34-
// Scan implements the database/sql Scanner interface.
36+
// Scan implements the [database/sql.Scanner] interface.
3537
func (dst *Bool) Scan(src any) error {
3638
if src == nil {
3739
*dst = Bool{}
@@ -61,7 +63,7 @@ func (dst *Bool) Scan(src any) error {
6163
return fmt.Errorf("cannot scan %T", src)
6264
}
6365

64-
// Value implements the database/sql/driver Valuer interface.
66+
// Value implements the [database/sql/driver.Valuer] interface.
6567
func (src Bool) Value() (driver.Value, error) {
6668
if !src.Valid {
6769
return nil, nil
@@ -70,6 +72,7 @@ func (src Bool) Value() (driver.Value, error) {
7072
return src.Bool, nil
7173
}
7274

75+
// MarshalJSON implements the [encoding/json.Marshaler] interface.
7376
func (src Bool) MarshalJSON() ([]byte, error) {
7477
if !src.Valid {
7578
return []byte("null"), nil
@@ -82,6 +85,7 @@ func (src Bool) MarshalJSON() ([]byte, error) {
8285
}
8386
}
8487

88+
// UnmarshalJSON implements the [encoding/json.Unmarshaler] interface.
8589
func (dst *Bool) UnmarshalJSON(b []byte) error {
8690
var v *bool
8791
err := json.Unmarshal(b, &v)

pgtype/box.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,16 +24,18 @@ type Box struct {
2424
Valid bool
2525
}
2626

27+
// ScanBox implements the [BoxScanner] interface.
2728
func (b *Box) ScanBox(v Box) error {
2829
*b = v
2930
return nil
3031
}
3132

33+
// BoxValue implements the [BoxValuer] interface.
3234
func (b Box) BoxValue() (Box, error) {
3335
return b, nil
3436
}
3537

36-
// Scan implements the database/sql Scanner interface.
38+
// Scan implements the [database/sql.Scanner] interface.
3739
func (dst *Box) Scan(src any) error {
3840
if src == nil {
3941
*dst = Box{}
@@ -48,7 +50,7 @@ func (dst *Box) Scan(src any) error {
4850
return fmt.Errorf("cannot scan %T", src)
4951
}
5052

51-
// Value implements the database/sql/driver Valuer interface.
53+
// Value implements the [database/sql/driver.Valuer] interface.
5254
func (src Box) Value() (driver.Value, error) {
5355
if !src.Valid {
5456
return nil, nil

pgtype/circle.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,16 +25,18 @@ type Circle struct {
2525
Valid bool
2626
}
2727

28+
// ScanCircle implements the [CircleScanner] interface.
2829
func (c *Circle) ScanCircle(v Circle) error {
2930
*c = v
3031
return nil
3132
}
3233

34+
// CircleValue implements the [CircleValuer] interface.
3335
func (c Circle) CircleValue() (Circle, error) {
3436
return c, nil
3537
}
3638

37-
// Scan implements the database/sql Scanner interface.
39+
// Scan implements the [database/sql.Scanner] interface.
3840
func (dst *Circle) Scan(src any) error {
3941
if src == nil {
4042
*dst = Circle{}
@@ -49,7 +51,7 @@ func (dst *Circle) Scan(src any) error {
4951
return fmt.Errorf("cannot scan %T", src)
5052
}
5153

52-
// Value implements the database/sql/driver Valuer interface.
54+
// Value implements the [database/sql/driver.Valuer] interface.
5355
func (src Circle) Value() (driver.Value, error) {
5456
if !src.Valid {
5557
return nil, nil

pgtype/date.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,13 @@ type Date struct {
2626
Valid bool
2727
}
2828

29+
// ScanDate implements the [DateScanner] interface.
2930
func (d *Date) ScanDate(v Date) error {
3031
*d = v
3132
return nil
3233
}
3334

35+
// DateValue implements the [DateValuer] interface.
3436
func (d Date) DateValue() (Date, error) {
3537
return d, nil
3638
}
@@ -40,7 +42,7 @@ const (
4042
infinityDayOffset = 2147483647
4143
)
4244

43-
// Scan implements the database/sql Scanner interface.
45+
// Scan implements the [database/sql.Scanner] interface.
4446
func (dst *Date) Scan(src any) error {
4547
if src == nil {
4648
*dst = Date{}
@@ -58,7 +60,7 @@ func (dst *Date) Scan(src any) error {
5860
return fmt.Errorf("cannot scan %T", src)
5961
}
6062

61-
// Value implements the database/sql/driver Valuer interface.
63+
// Value implements the [database/sql/driver.Valuer] interface.
6264
func (src Date) Value() (driver.Value, error) {
6365
if !src.Valid {
6466
return nil, nil
@@ -70,6 +72,7 @@ func (src Date) Value() (driver.Value, error) {
7072
return src.Time, nil
7173
}
7274

75+
// MarshalJSON implements the [encoding/json.Marshaler] interface.
7376
func (src Date) MarshalJSON() ([]byte, error) {
7477
if !src.Valid {
7578
return []byte("null"), nil
@@ -89,6 +92,7 @@ func (src Date) MarshalJSON() ([]byte, error) {
8992
return json.Marshal(s)
9093
}
9194

95+
// UnmarshalJSON implements the [encoding/json.Unmarshaler] interface.
9296
func (dst *Date) UnmarshalJSON(b []byte) error {
9397
var s *string
9498
err := json.Unmarshal(b, &s)

pgtype/float4.go

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,26 +16,29 @@ type Float4 struct {
1616
Valid bool
1717
}
1818

19-
// ScanFloat64 implements the Float64Scanner interface.
19+
// ScanFloat64 implements the [Float64Scanner] interface.
2020
func (f *Float4) ScanFloat64(n Float8) error {
2121
*f = Float4{Float32: float32(n.Float64), Valid: n.Valid}
2222
return nil
2323
}
2424

25+
// Float64Value implements the [Float64Valuer] interface.
2526
func (f Float4) Float64Value() (Float8, error) {
2627
return Float8{Float64: float64(f.Float32), Valid: f.Valid}, nil
2728
}
2829

30+
// ScanInt64 implements the [Int64Scanner] interface.
2931
func (f *Float4) ScanInt64(n Int8) error {
3032
*f = Float4{Float32: float32(n.Int64), Valid: n.Valid}
3133
return nil
3234
}
3335

36+
// Int64Value implements the [Int64Valuer] interface.
3437
func (f Float4) Int64Value() (Int8, error) {
3538
return Int8{Int64: int64(f.Float32), Valid: f.Valid}, nil
3639
}
3740

38-
// Scan implements the database/sql Scanner interface.
41+
// Scan implements the [database/sql.Scanner] interface.
3942
func (f *Float4) Scan(src any) error {
4043
if src == nil {
4144
*f = Float4{}
@@ -58,21 +61,23 @@ func (f *Float4) Scan(src any) error {
5861
return fmt.Errorf("cannot scan %T", src)
5962
}
6063

61-
// Value implements the database/sql/driver Valuer interface.
64+
// Value implements the [database/sql/driver.Valuer] interface.
6265
func (f Float4) Value() (driver.Value, error) {
6366
if !f.Valid {
6467
return nil, nil
6568
}
6669
return float64(f.Float32), nil
6770
}
6871

72+
// MarshalJSON implements the [encoding/json.Marshaler] interface.
6973
func (f Float4) MarshalJSON() ([]byte, error) {
7074
if !f.Valid {
7175
return []byte("null"), nil
7276
}
7377
return json.Marshal(f.Float32)
7478
}
7579

80+
// UnmarshalJSON implements the [encoding/json.Unmarshaler] interface.
7681
func (f *Float4) UnmarshalJSON(b []byte) error {
7782
var n *float32
7883
err := json.Unmarshal(b, &n)

pgtype/float8.go

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,26 +24,29 @@ type Float8 struct {
2424
Valid bool
2525
}
2626

27-
// ScanFloat64 implements the Float64Scanner interface.
27+
// ScanFloat64 implements the [Float64Scanner] interface.
2828
func (f *Float8) ScanFloat64(n Float8) error {
2929
*f = n
3030
return nil
3131
}
3232

33+
// Float64Value implements the [Float64Valuer] interface.
3334
func (f Float8) Float64Value() (Float8, error) {
3435
return f, nil
3536
}
3637

38+
// ScanInt64 implements the [Int64Scanner] interface.
3739
func (f *Float8) ScanInt64(n Int8) error {
3840
*f = Float8{Float64: float64(n.Int64), Valid: n.Valid}
3941
return nil
4042
}
4143

44+
// Int64Value implements the [Int64Valuer] interface.
4245
func (f Float8) Int64Value() (Int8, error) {
4346
return Int8{Int64: int64(f.Float64), Valid: f.Valid}, nil
4447
}
4548

46-
// Scan implements the database/sql Scanner interface.
49+
// Scan implements the [database/sql.Scanner] interface.
4750
func (f *Float8) Scan(src any) error {
4851
if src == nil {
4952
*f = Float8{}
@@ -66,21 +69,23 @@ func (f *Float8) Scan(src any) error {
6669
return fmt.Errorf("cannot scan %T", src)
6770
}
6871

69-
// Value implements the database/sql/driver Valuer interface.
72+
// Value implements the [database/sql/driver.Valuer] interface.
7073
func (f Float8) Value() (driver.Value, error) {
7174
if !f.Valid {
7275
return nil, nil
7376
}
7477
return f.Float64, nil
7578
}
7679

80+
// MarshalJSON implements the [encoding/json.Marshaler] interface.
7781
func (f Float8) MarshalJSON() ([]byte, error) {
7882
if !f.Valid {
7983
return []byte("null"), nil
8084
}
8185
return json.Marshal(f.Float64)
8286
}
8387

88+
// UnmarshalJSON implements the [encoding/json.Unmarshaler] interface.
8489
func (f *Float8) UnmarshalJSON(b []byte) error {
8590
var n *float64
8691
err := json.Unmarshal(b, &n)

pgtype/hstore.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,18 @@ type HstoreValuer interface {
2222
// associated with its keys.
2323
type Hstore map[string]*string
2424

25+
// ScanHstore implements the [HstoreScanner] interface.
2526
func (h *Hstore) ScanHstore(v Hstore) error {
2627
*h = v
2728
return nil
2829
}
2930

31+
// HstoreValue implements the [HstoreValuer] interface.
3032
func (h Hstore) HstoreValue() (Hstore, error) {
3133
return h, nil
3234
}
3335

34-
// Scan implements the database/sql Scanner interface.
36+
// Scan implements the [database/sql.Scanner] interface.
3537
func (h *Hstore) Scan(src any) error {
3638
if src == nil {
3739
*h = nil
@@ -46,7 +48,7 @@ func (h *Hstore) Scan(src any) error {
4648
return fmt.Errorf("cannot scan %T", src)
4749
}
4850

49-
// Value implements the database/sql/driver Valuer interface.
51+
// Value implements the [database/sql/driver.Valuer] interface.
5052
func (h Hstore) Value() (driver.Value, error) {
5153
if h == nil {
5254
return nil, nil

pgtype/inet.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ type NetipPrefixValuer interface {
2424
NetipPrefixValue() (netip.Prefix, error)
2525
}
2626

27-
// InetCodec handles both inet and cidr PostgreSQL types. The preferred Go types are netip.Prefix and netip.Addr. If
27+
// InetCodec handles both inet and cidr PostgreSQL types. The preferred Go types are [netip.Prefix] and [netip.Addr]. If
2828
// IsValid() is false then they are treated as SQL NULL.
2929
type InetCodec struct{}
3030

0 commit comments

Comments
 (0)