-
Notifications
You must be signed in to change notification settings - Fork 0
/
codingKey.go.tmpl
19 lines (14 loc) · 1.06 KB
/
codingKey.go.tmpl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
{{- define "codingKey" -}}
{{- /* Prints field name while prioritizing "json" field meta */ -}}
{{- $field := .Field -}}
{{- $fieldName := $field.Name -}}
{{- range $meta := $field.Meta -}}
{{- if exists $meta "json" -}}
{{- $fieldName = get $meta "json" | split "," | first -}}
{{- end -}}
{{- end -}}
{{- if in (toLower $fieldName) "as" "as?" "break" "class" "continue" "do" "else" "false" "for" "fun" "if" "in" "interface" "is" "null" "object" "package" "return" "super" "this" "throw" "true" "try" "typealias" "val" "var" "when" "while" "by" "catch" "constructor" "delegate" "dynamic" "field" "file" "finally" "get" "import" "init" "param" "property" "receiver" "set" "setparam" "where" "actual" "abstract" "annotation" "companion" "const" "crossinline" "data" "enum" "expect" "external" "final" "infix" "inline" "inner" "internal" "lateinit" "noinline" "open" "operator" "out" "override" "private" "protected" "public" "reified" "sealed" "suspend" "tailrec" "vararg" -}}
{{- $fieldName := (printf "`%v`" $fieldName) -}}
{{- end -}}
{{- $fieldName -}}
{{- end -}}