mirror of
https://github.com/bitmagnet-io/bitmagnet.git
synced 2026-05-06 12:27:01 -04:00
c16f76130c
The classifier has been re-implemented and now uses a DSL allowing for full customisation. Several bugs have also been fixed. - Closes https://github.com/bitmagnet-io/bitmagnet/issues/182 - Closes https://github.com/bitmagnet-io/bitmagnet/issues/70 - Closes https://github.com/bitmagnet-io/bitmagnet/issues/68 - Hopefully fixes https://github.com/bitmagnet-io/bitmagnet/issues/126
18 lines
401 B
Go
18 lines
401 B
Go
package classifier
|
|
|
|
import (
|
|
"github.com/iancoleman/strcase"
|
|
"github.com/mitchellh/mapstructure"
|
|
)
|
|
|
|
func newDecoder[T any](target *T) (*mapstructure.Decoder, error) {
|
|
return mapstructure.NewDecoder(&mapstructure.DecoderConfig{
|
|
Result: target,
|
|
MatchName: func(mapKey, fieldName string) bool {
|
|
return mapKey == strcase.ToSnake(fieldName)
|
|
},
|
|
ErrorUnused: true,
|
|
TagName: "json",
|
|
})
|
|
}
|