About this Go comparison
Because gofmt keeps Go formatting consistent, a Go diff usually shows only meaningful changes: renamed functions, different values, new branches. That makes comparing two versions of a Go file especially clean.
Use it to review a change before sending it, compare two solutions, or check what a code generator rewrote.
What changed in this sample
add(a int, b int)was renamed tocalculate(x int, y int).- In
main,x,yandsumbecamea,bandtotal, set to 12 and 18. - The threshold moved from 15 to 20, with the printed messages updated to match.
Tips for comparing Go
- Compare go.mod and go.sum
- Dependency bumps show up as changed version strings; the Characters highlight marks just the digits that moved.
- Tabs are part of Go
- gofmt indents with tabs. If one version was pasted with spaces, Ignore whitespace treats them as equal.
- Generated code
- For large generated files, keep Fold unchanged on and use the arrows to step through the changes.
- Patch for review
- Download .diff file gives a unified diff ready for git apply or a code review tool.
How to compare Go online
- Paste the older version into Original and the newer one into Changed, or open a file on each side.
- Check that the syntax menu says Go, then pick split or unified view.
- Step through the changes with the arrows or Alt ↓, and use Settings for options such as ignoring blank lines.
- Save the comparison in your browser, share a link, or download it as a .diff, HTML or PDF.
Go comparison: questions
Can I compare two .go files?
Yes. Open or drop them on the panes and Go highlighting is selected automatically.
Does it run gofmt?
No. It compares the text as it is. Format both files first if they were not formatted the same way.
Is the code sent to a server?
No. Everything stays in your browser unless you create a share link.