mojang cant get their cases straight
i had to implement like 4 cases just to parse that file
This commit is contained in:
+17
-2
@@ -18,8 +18,11 @@ type Format struct {
|
||||
Name string
|
||||
requireAll bool
|
||||
errorOnExtra bool
|
||||
decoders map[reflect.Type]func(any, string) (any, error)
|
||||
encoders map[reflect.Type]func(any, string) (any, error)
|
||||
trySnakeCase bool
|
||||
tryLowCase bool
|
||||
|
||||
decoders map[reflect.Type]func(any, string) (any, error)
|
||||
encoders map[reflect.Type]func(any, string) (any, error)
|
||||
}
|
||||
|
||||
func NewFormat(name string, opts ...Option) *Format {
|
||||
@@ -48,6 +51,18 @@ func WithErrorOnExtra() Option {
|
||||
}
|
||||
}
|
||||
|
||||
func WithTrySnakeCase() Option {
|
||||
return func(f *Format) {
|
||||
f.trySnakeCase = true
|
||||
}
|
||||
}
|
||||
|
||||
func WithTryLowCase() Option {
|
||||
return func(f *Format) {
|
||||
f.tryLowCase = true
|
||||
}
|
||||
}
|
||||
|
||||
func WithTypeCodec(decodeFn, encodeFn any) Option {
|
||||
dt := reflect.TypeOf(decodeFn)
|
||||
et := reflect.TypeOf(encodeFn)
|
||||
|
||||
Reference in New Issue
Block a user