Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gno fmt adds an extra line at the end of the file #2633

Closed
tbruyelle opened this issue Jul 26, 2024 · 3 comments
Closed

gno fmt adds an extra line at the end of the file #2633

tbruyelle opened this issue Jul 26, 2024 · 3 comments
Assignees

Comments

@tbruyelle
Copy link
Contributor

tbruyelle commented Jul 26, 2024

Since it is asserted in the tests (See screenshot of gnovm/pkg/gnofmt/processes_test.go), it looks like this extra line is added on purpose, but I wonder what's the reason of having this difference compared to go fmt.

image

cc @gfanton

@tbruyelle tbruyelle changed the title gno fmt adds an extra line at the end of the file gno fmt adds an extra line at the end of the file Jul 26, 2024
@gfanton gfanton self-assigned this Jul 28, 2024
@gfanton
Copy link
Member

gfanton commented Jul 28, 2024

Thanks for reporting this !

So, actually go fmt makes sure that a newline exists at the end of the file. The picture of the test you sent asserts this (under the hood gnofmt/gnoimports is used to format the file).

But you are right, there is another newline being printed out ($ means newline, % means EOF):
Screenshot 2024-07-28 at 09 59 04

This is due to a Println instead of a Printf inside the cmd itself while writing the file to disk.

I will fix this asap.

@gfanton
Copy link
Member

gfanton commented Jul 28, 2024

After double-checking, this behavior only exists when printing on stdout (without the -w flag). It was intentional to have a space between files for distinction (gno fmt file_1.gno file_2.gno ... ), but upon second thought, it might be more coherent and intuitive to have the same behavior as go fmt and print out files without consideration of newlines between printed files.

@tbruyelle
Copy link
Contributor Author

Great, thanks for the fix!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Development

No branches or pull requests

2 participants