Skip to content
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

replace directive #346

Merged
merged 11 commits into from
Jul 2, 2024
76 changes: 76 additions & 0 deletions _generated/replace.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
package _generated

//go:generate msgp
//msgp:replace Any with:any
//msgp:replace MapString with:CompatibleMapString
//msgp:replace MapAny with:map[string]any
//msgp:replace SliceString with:[]string
//msgp:replace SliceInt with:CompatibleSliceInt
//msgp:replace Array8 with:CompatibleArray8
//msgp:replace Array16 with:[16]byte
//msgp:replace String with:string
//msgp:replace Int with:CompatibleInt
//msgp:replace Uint with:uint
//msgp:replace Float32 with:CompatibleFloat32
//msgp:replace Float64 with:CompatibleFloat64
//msgp:replace Time with:time.Time
//msgp:replace Duration with:time.Duration
//msgp:replace StructA with:CompatibleStructA
//msgp:replace StructB with:CompatibleStructB
//msgp:replace StructC with:CompatibleStructC
//msgp:replace StructD with:CompatibleStructD
//msgp:replace StructI with:CompatibleStructI
//msgp:replace StructS with:CompatibleStructS

type (
CompatibleMapString map[string]string
CompatibleArray8 [8]byte
CompatibleInt int
CompatibleFloat32 float32
CompatibleFloat64 float64
CompatibleSliceInt []Int

// Doesn't work
// CompatibleTime time.Time

CompatibleStructA struct {
StructB StructB
Int Int
}

CompatibleStructB struct {
StructC StructC
Any Any
Array8 Array8
}

CompatibleStructC struct {
StructD StructD
Float64 Float32
Float32 Float64
}

CompatibleStructD struct {
Time Time
Duration Duration
MapString MapString
}

CompatibleStructI struct {
Int *Int
Uint *Uint
}

CompatibleStructS struct {
Slice SliceInt
}

Dummy struct {
StructA StructA
StructI StructI
StructS StructS
Array16 Array16
Uint Uint
String String
}
)
54 changes: 54 additions & 0 deletions _generated/replace_ext.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
package _generated

import "time"

// external types to test replace directive

type (
MapString map[string]string
MapAny map[string]any
SliceString []String
SliceInt []Int
Array8 [8]byte
Array16 [16]byte
Int int
Uint uint
String string
Float32 float32
Float64 float64
Time time.Time
Duration time.Duration
Any any

StructA struct {
StructB StructB
Int Int
}

StructB struct {
StructC StructC
Any Any
Array8 Array8
}

StructC struct {
StructD StructD
Float64 Float32
Float32 Float64
}

StructD struct {
Time Time
Duration Duration
MapString MapString
}

StructI struct {
Int *Int
Uint *Uint
}

StructS struct {
Slice SliceInt
}
)
Loading
Loading