mirror of
https://github.com/tinygo-org/net.git
synced 2026-07-26 08:18:39 +00:00
e82bdb20d3
Rewrite the bash upgrade script as a standalone Go program for better portability and maintainability. The tool preserves all existing behavior: three-category file classification, dry-run mode, Go source resolution (gvm/GOROOT/download), 3-way merge via diff3, and colored output. Build: cd tools/upgrade && go build -o upgrade . Run: ./tools/upgrade/upgrade --dry-run Signed-off-by: deadprogram <ron@hybridgroup.com>
upgrade
Automates the TinyGo net package upgrade process by backporting
changes from upstream Go stdlib and generating comparison reports.
It handles three categories of files:
- TinyGo-only (e.g.
netdev.go,tlssock.go) — skipped entirely - Unmodified copies — replaced directly from upstream
- Modified files (with
// TINYGOmarkers) — 3-way merged viadiff3
Prerequisites
diffanddiff3(from GNU diffutils)- Go source trees are resolved automatically:
- gvm installs at
~/.gvm/gos/ - Active
GOROOTif the version matches - Downloaded from
https://go.dev/dl/into.upgrade-work/
- gvm installs at
Build
cd tools/upgrade
go build -o upgrade .
This produces the upgrade binary. It must be run from the net
package root directory (the repository root).
Usage
# From the net package root:
./tools/upgrade/upgrade [flags]
Flags
| Flag | Default | Description |
|---|---|---|
--dry-run |
false |
Preview changes without modifying files |
--cur |
1.21.4 |
Go version the TinyGo net package is currently based on |
--upstream |
1.26.2 |
Target upstream Go version to upgrade to |
--file |
Process a single file instead of all files |
Examples
# Preview what would change
./tools/upgrade/upgrade --dry-run
# Perform the upgrade
./tools/upgrade/upgrade --cur 1.21.4 --upstream 1.26.2
# Preview a single file
./tools/upgrade/upgrade --dry-run --file dial.go
Output
Reports are written to .upgrade-report/ in the net package root:
summary.txt— one-line status per filediffs/— unified diffs showing upstream and TinyGo changesmerged/— merge results (only in apply mode)
Files with merge conflicts are saved as <file>.conflicted alongside
the original.
After upgrading
- Review and resolve any
.conflictedfiles - Check for files missing from upstream (may have been renamed/removed)
- Verify
// TINYGOcomments are preserved - Test with TinyGo example/net examples
- Update
README.mdversion references