Define terminalWidth on GOOS=wasip1 via the appengine/js stub - #241
Open
calvinrp wants to merge 1 commit into
Open
Define terminalWidth on GOOS=wasip1 via the appengine/js stub#241calvinrp wants to merge 1 commit into
calvinrp wants to merge 1 commit into
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Hi, and thanks for maintaining pb!
Since Go 1.21 added
GOOS=wasip1(WASI preview 1), building packagepbfor that platform fails, because none of the existingterminalWidthimplementations is selected there:pb_x.gois gated to the Unix-like platforms,pb_win.goto Windows,pb_plan9.goto Plan 9, andpb_appengine.gotoappengine/js. This also breaks downstream users of the v1 line on wasip1 — for examplegithub.com/codesenberg/bombardier, which depends onpbv1.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 likeGetWidthalready fall back to the default width whenterminalWidthreturns an error. This PR just addswasip1to 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, selectingpb_appengine.gogo list -f '{{.GoFiles}}'output on linux/darwin/windows is unchangedHappy to adjust (e.g. add a
//go:buildline as well) if you prefer.🤖 Generated with Claude Code