-
Notifications
You must be signed in to change notification settings - Fork 383
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
feat: Add the stdlib_diff tool to compare gno and go standard libraries #1425
feat: Add the stdlib_diff tool to compare gno and go standard libraries #1425
Conversation
…tion is the standard gno library
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for your contribution!
Sorry for the wait, this is an initial to improve. Nice work, but you can improve.
Some functionality missing on the generated report:
- Formatting is still very funky. Use CSS to render tabs correctly; they should render as 4 spaces.
- Ideally, for the added/deleted lines, make the
+
and-
symbols non selectable. This makes it so that if I select the lines in either side of the page I can copy and paste the code without copying the symbols. - I believe the report's performance could be improved. Consider using the library I mention in the comments (diffmatchpatch) and parallelizing execution. You can parallelize execution by having a goroutine trying to first of all find all of the directories in the source and destination, and then sending off to a channel individual package names.
- The tool does not currently perform diffing recursively. Ie. creating the report on my stdlibs it does not generate a diff for package
regexp/syntax
. Consider searching using something likefilepath.WalkDir
. - On the report, please make the lines which are == greyed out (putting css
opacity: 0.75
probably works)
package main | ||
|
||
import ( | ||
"slices" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
seeing as you are importing slices, please add a go.mod
file in this directory putting the go version at go 1.21
f, err := os.Open(dirPath) | ||
if err != nil { | ||
return []string{}, nil | ||
} | ||
|
||
defer func() { | ||
if err := f.Close(); err != nil { | ||
fmt.Fprintln(os.Stderr, "can't close "+dirPath) | ||
} | ||
}() | ||
|
||
filesInfo, err := f.Readdir(0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Prefer os.ReadDir
@FloRichardAloeCorp I see some comments are still pending (including what I added in the top-level comment). Would you like me to do a second round of review or are you still making changes? Thanks! |
@thehowl I still have work to do, I was waiting for your answers. I ping you back when I have finished. |
@thehowl what's the status on this PR? |
@zivkovicmilos I'll get around to finishing what Florian started, eventually 🫠 |
Being continued in #2869; closing. |
As requested by the issue https://github.com/gnolang/gno/issues/1310, the aim of this pull request is to add a tool under the misc directory to compare the Gno and Go standard libraries.
The tool generates a differences report per package.
To test the tool, build it, and refer to the README for usage instructions. The tool can be used in both ways: comparing Go to Gno or comparing Gno to Go.
I'm questioning the relevance of adding unit tests to this tool. If you believe it needs some, just let me know!
Contributors' checklist...
BREAKING CHANGE: xxx
message was included in the description