sdomino/scribble

Newline at end of file no longer working (regression)

Closed this issue · 1 comments

I noticed that the change to add a newline to the end of json files, that got committed in 40263ff was reverted again without any comment in 4116320 (the otherwise very nice pull request #21).

Given that there was no note regarding that, I'm thinking that it was an inadvertent regression. I really like having the newline.

Looks like a very simple fix, just to add that code back at the end of write() prior to writing the marshaled data to temp file.

	// marshal the pointer to a non-struct and indent with tab
	b, err := json.MarshalIndent(v, "", "\t")
	if err != nil {
		return err
	}

	// add newline to the end
	b = append(b, byte('\n'))

	// write marshaled data to the temp file
	if err := ioutil.WriteFile(tmpPath, b, 0644); err != nil {
		return err

Thanks for your feedback! I actually haven't worked on this project in some time. I'd love some help if you had the time to submit a PR.