Skip to content

Commit be10af1

Browse files
committed
Change default jsontemplate to ""
1 parent 08bc81e commit be10af1

File tree

2 files changed

+9
-10
lines changed

2 files changed

+9
-10
lines changed

Diff for: Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
VERSION = 3.0.0
1+
VERSION = 3.0.1
22

33
PACKAGES := $(shell go list -f {{.Dir}} ./...)
44
GOFILES := $(addsuffix /*.go,$(PACKAGES))

Diff for: cmd/ts/main.go

+8-9
Original file line numberDiff line numberDiff line change
@@ -118,9 +118,6 @@ func init() {
118118
if config.start != "" {
119119
start = regexp.MustCompile(config.start)
120120
}
121-
if config.readJSON && config.jsonTemplate == "" {
122-
config.jsonTemplate = "{{.}}"
123-
}
124121
if config.jsonTemplate != "" {
125122
config.readJSON = true
126123
jsonTemplate = template.Must(template.New("-jsontemplate").Option("missingkey=zero").Parse(config.jsonTemplate))
@@ -154,16 +151,18 @@ func main() {
154151
line.I = i
155152
match := line.Text
156153
if config.readJSON {
157-
b.Reset()
158154
line.Object = new(interface{})
159155
if err := json.Unmarshal([]byte(line.Text), &line.Object); err != nil {
160-
fmt.Fprintln(os.Stderr, "parse error:", err)
156+
fmt.Fprintln(os.Stderr, "JSON parse error:", err)
161157
}
162-
if err := jsonTemplate.Execute(b, line.Object); err != nil {
163-
fmt.Fprintln(os.Stderr, "template error:", err)
158+
if jsonTemplate != nil {
159+
b.Reset()
160+
if err := jsonTemplate.Execute(b, line.Object); err != nil {
161+
fmt.Fprintln(os.Stderr, "template error:", err)
162+
}
163+
line.JSONText = b.String()
164+
match = line.JSONText
164165
}
165-
line.JSONText = b.String()
166-
match = line.JSONText
167166
}
168167
if err := printer(&line); err != nil {
169168
fmt.Fprintln(os.Stderr, "output error:", err)

0 commit comments

Comments
 (0)