Used by AWS, Microsoft and 200+ other open-source projects. A tiny, dependency-free Go library for reading terminal width and height (columns × rows) on the machine your process is attached to.
Go
37
13 commits
updated Apr 6, 2026
A tiny, dependency-free Go library for reading terminal width and height (columns × rows) on the machine your process is attached to.
GetConsoleScreenBufferInfo on Windowsgolang.org/x/term?x/term (and the wider x/ family) is the right choice when you want a full terminal feature set — raw mode, bracketed paste, cursor APIs, and more. It pulls in golang.org/x/sys and a larger API surface.
consolesize-go is for when you only need window size: one function, no extra module graph, and nothing else to learn or audit. That is a deliberate trade-off, not a knock on x/term.
go get github.com/nathan-fiscaletti/consolesize-go
package main
import (
"fmt"
"github.com/nathan-fiscaletti/consolesize-go"
)
func main() {
cols, rows := consolesize.GetConsoleSize()
fmt.Printf("columns: %d, rows: %d\n", cols, rows)
}
GetConsoleSize returns (columns, rows).
Minimal mains that only read terminal size are built side-by-side under sizecmp/: one links this module, the other links golang.org/x/term (which pulls x/sys). Both use the same go build flags.
The script strips symbols (-ldflags=-s -w) and uses -trimpath so paths on your machine do not affect the build. It prints byte sizes and the delta for your GOOS/GOARCH and Go toolchain. Exact numbers change across releases; the typical pattern is a smaller binary when you avoid x/term + x/sys for size-only callers. On an Apple M5 this saves ~17kb.
./sizecmp/compare.sh
go version: go version go1.26.1 darwin/arm64
GOOS=darwin GOARCH=arm64
flags: go build -ldflags=-s -w -trimpath
consolesize-go 1454754 bytes
golang.org/x/term 1471874 bytes
delta (x/term - consolesize-go) +17120 byte
Based on: network/dependents as of April 6th, 2026.
MIT — see LICENSE.
Used by AWS, Microsoft and 200+ other open-source projects. A tiny, dependency-free Go library for reading terminal width and height (columns × rows) on the machine your process is attached to.
Go
37
13 commits
updated Apr 6, 2026
A tiny, dependency-free Go library for reading terminal width and height (columns × rows) on the machine your process is attached to.
GetConsoleScreenBufferInfo on Windowsgolang.org/x/term?x/term (and the wider x/ family) is the right choice when you want a full terminal feature set — raw mode, bracketed paste, cursor APIs, and more. It pulls in golang.org/x/sys and a larger API surface.
consolesize-go is for when you only need window size: one function, no extra module graph, and nothing else to learn or audit. That is a deliberate trade-off, not a knock on x/term.
go get github.com/nathan-fiscaletti/consolesize-go
package main
import (
"fmt"
"github.com/nathan-fiscaletti/consolesize-go"
)
func main() {
cols, rows := consolesize.GetConsoleSize()
fmt.Printf("columns: %d, rows: %d\n", cols, rows)
}
GetConsoleSize returns (columns, rows).
Minimal mains that only read terminal size are built side-by-side under sizecmp/: one links this module, the other links golang.org/x/term (which pulls x/sys). Both use the same go build flags.
The script strips symbols (-ldflags=-s -w) and uses -trimpath so paths on your machine do not affect the build. It prints byte sizes and the delta for your GOOS/GOARCH and Go toolchain. Exact numbers change across releases; the typical pattern is a smaller binary when you avoid x/term + x/sys for size-only callers. On an Apple M5 this saves ~17kb.
./sizecmp/compare.sh
go version: go version go1.26.1 darwin/arm64
GOOS=darwin GOARCH=arm64
flags: go build -ldflags=-s -w -trimpath
consolesize-go 1454754 bytes
golang.org/x/term 1471874 bytes
delta (x/term - consolesize-go) +17120 byte
Based on: network/dependents as of April 6th, 2026.
MIT — see LICENSE.