From 7b219253661560e60d284e3cddfb912dc49862fc Mon Sep 17 00:00:00 2001 From: Fernandez Ludovic Date: Mon, 3 Jan 2022 09:25:29 +0100 Subject: [PATCH] feat: handle empty name --- Makefile | 2 +- tagliatelle.go | 3 +-- testdata/src/a/sample.go | 2 +- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index f66a398..196f70c 100644 --- a/Makefile +++ b/Makefile @@ -12,4 +12,4 @@ check: golangci-lint run build: - go build -v -ldflags "-s -w" -trimpath ./cmd/tagliatelle/ + go build -ldflags "-s -w" -trimpath ./cmd/tagliatelle/ diff --git a/tagliatelle.go b/tagliatelle.go index dfb302b..801f9d3 100644 --- a/tagliatelle.go +++ b/tagliatelle.go @@ -97,8 +97,7 @@ func analyze(pass *analysis.Pass, config Config, n *ast.StructType, field *ast.F } if value == "" { - // skip empty value, it can change in the future - continue + value = fieldName } converter, err := getConverter(convName) diff --git a/testdata/src/a/sample.go b/testdata/src/a/sample.go index 62f5fbf..f2c1565 100644 --- a/testdata/src/a/sample.go +++ b/testdata/src/a/sample.go @@ -25,6 +25,6 @@ type Bur struct { Name string Value string `yaml:"Value"` // want `yaml\(camel\): got 'Value' want 'value'` More string `json:"-"` - Also string `json:",omitempty"` + Also string `json:",omitempty"` // want `json\(camel\): got 'Also' want 'also'` ReqPerS string `avro:"req_per_s"` }