Skip to content

Define terminalWidth on GOOS=wasip1 via the appengine/js stub - #241

Open
calvinrp wants to merge 1 commit into
cheggaaa:masterfrom
calvinrp:wasip1-terminal-width
Open

Define terminalWidth on GOOS=wasip1 via the appengine/js stub#241
calvinrp wants to merge 1 commit into
cheggaaa:masterfrom
calvinrp:wasip1-terminal-width

Conversation

@calvinrp

Copy link
Copy Markdown

Hi, and thanks for maintaining pb!

Since Go 1.21 added GOOS=wasip1 (WASI preview 1), building package pb for that platform fails, because none of the existing terminalWidth implementations is selected there:

pb.go:427:9: undefined: terminalWidth
pb.go:436:18: undefined: terminalWidth

pb_x.go is gated to the Unix-like platforms, pb_win.go to Windows, pb_plan9.go to Plan 9, and pb_appengine.go to appengine/js. This also breaks downstream users of the v1 line on wasip1 — for example github.com/codesenberg/bombardier, which depends on pb v1.

WASI preview 1 has no terminal-size API, so the appengine/js stub (return 0, errors.New("Not supported")) is the correct behavior there as well: callers like GetWidth already fall back to the default width when terminalWidth returns an error. This PR just adds wasip1 to that stub's build tags, matching the file's existing tag style.

Verified with Go 1.21+:

  • GOOS=wasip1 GOARCH=wasm go build . now succeeds, selecting pb_appengine.go
  • go list -f '{{.GoFiles}}' output on linux/darwin/windows is unchanged

Happy to adjust (e.g. add a //go:build line as well) if you prefer.

🤖 Generated with Claude Code

On wasip1 (supported since Go 1.21), none of the existing terminalWidth
implementations is selected: pb_x.go, pb_win.go, and pb_plan9.go are all
gated to other platforms, and pb_appengine.go is limited to appengine and
js. As a result any build of package pb for GOOS=wasip1 fails with:

    pb.go:427:9: undefined: terminalWidth
    pb.go:436:18: undefined: terminalWidth

WASI preview 1 has no terminal-size API, so the appengine/js stub
(return 0, "Not supported") is the correct behavior there too: callers
such as GetWidth already fall back to the default width when
terminalWidth returns an error.

Verified with Go 1.21+: GOOS=wasip1 GOARCH=wasm now selects
pb_appengine.go and 'go build' succeeds; file selection on all other
platforms is unchanged.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant