Skip to content

Commit 28f539c

Browse files
committed
Fix duplicate newline at end if using template
1 parent 82c4341 commit 28f539c

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

goreplace.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -453,7 +453,7 @@ func actionProcessStdinTemplate(changesets []changeset) (int) {
453453
}
454454

455455
content := parseContentAsTemplate(buffer.String(), changesets)
456-
fmt.Println(content.String())
456+
fmt.Print(content.String())
457457

458458
return 0
459459
}

tests/main.t

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -350,3 +350,22 @@ Testing template mode:
350350
this is the second line
351351
this is the third foobar line
352352
this is the last line
353+
354+
Testing template mode:
355+
356+
$ cat > test.txt <<EOF
357+
> {{23 -}} < {{- 45}}
358+
> {{.Arg.Foobar}}
359+
> this is a testline
360+
> this is the second line
361+
> this is the third foobar line
362+
> this is the last line
363+
> EOF
364+
$ cat test.txt | goreplace --mode=template --stdin -s Foobar -r ___xxx test.txt
365+
23<45
366+
___xxx
367+
this is a testline
368+
this is the second line
369+
this is the third foobar line
370+
this is the last line
371+

0 commit comments

Comments
 (0)