diff --git a/go.mod b/go.mod index 6f20d951fd..ad39d38fca 100644 --- a/go.mod +++ b/go.mod @@ -26,7 +26,7 @@ require ( github.com/google/go-cmp v0.7.0 github.com/google/uuid v1.6.0 github.com/hashicorp/go-version v1.6.0 - github.com/nathan-fiscaletti/consolesize-go v0.0.0-20210105204122-a87d9f614b9d + github.com/nathan-fiscaletti/consolesize-go v0.0.0-20260406063853-3bac975de715 github.com/onsi/ginkgo/v2 v2.17.1 github.com/onsi/gomega v1.30.0 github.com/openshift-online/ocm-api-model/clientapi v0.0.453 diff --git a/go.sum b/go.sum index 307b60824d..44d63be930 100644 --- a/go.sum +++ b/go.sum @@ -196,8 +196,8 @@ github.com/mtibben/percent v0.2.1 h1:5gssi8Nqo8QU/r2pynCm+hBQHpkB/uNK7BJCFogWdzs github.com/mtibben/percent v0.2.1/go.mod h1:KG9uO+SZkUp+VkRHsCdYQV3XSZrrSpR3O9ibNBTZrns= github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 h1:C3w9PqII01/Oq1c1nUAm88MOHcQC9l5mIlSMApZMrHA= github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ= -github.com/nathan-fiscaletti/consolesize-go v0.0.0-20210105204122-a87d9f614b9d h1:PQW4Aqovdqc9efHl9EVA+bhKmuZ4ME1HvSYYDvaDiK0= -github.com/nathan-fiscaletti/consolesize-go v0.0.0-20210105204122-a87d9f614b9d/go.mod h1:cxIIfNMTwff8f/ZvRouvWYF6wOoO7nj99neWSx2q/Es= +github.com/nathan-fiscaletti/consolesize-go v0.0.0-20260406063853-3bac975de715 h1:FiSC3sz/k2SYB32YJ1bLlBVB7Li0N7n6jcYa9Knq/60= +github.com/nathan-fiscaletti/consolesize-go v0.0.0-20260406063853-3bac975de715/go.mod h1:DQpEqvLUU3b35AJUVu5P6LFn/RY3qj4WtMjvrcE8gto= github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno= github.com/onsi/ginkgo/v2 v2.17.1 h1:V++EzdbhI4ZV4ev0UTIj0PzhzOcReJFyJaLjtSF55M8= github.com/onsi/ginkgo/v2 v2.17.1/go.mod h1:llBI3WDLL9Z6taip6f33H76YcWtJv+7R3HigUjbIBOs= diff --git a/vendor/github.com/nathan-fiscaletti/consolesize-go/README.md b/vendor/github.com/nathan-fiscaletti/consolesize-go/README.md index 224ef534cb..a4de0b61ed 100644 --- a/vendor/github.com/nathan-fiscaletti/consolesize-go/README.md +++ b/vendor/github.com/nathan-fiscaletti/consolesize-go/README.md @@ -1,14 +1,30 @@ # consolesize-go +[![Sponsor Me!](https://img.shields.io/badge/%F0%9F%92%B8-Sponsor%20Me!-blue)](https://github.com/sponsors/nathan-fiscaletti) [![GoDoc](https://godoc.org/github.com/nathan-fiscaletti/consolesize-go?status.svg)](https://godoc.org/github.com/nathan-fiscaletti/consolesize-go) -[![Go Report Card](https://goreportcard.com/badge/github.com/nathan-fiscaletti/consolesize-go)](https://goreportcard.com/report/github.com/nathan-fiscaletti/consolesize-go) -**consolesize-go** is a library that will allow you to read the size of any console window on both **Unix** and **Windows** systems. +A tiny, dependency-free Go library for reading **terminal width and height** (columns × rows) on the machine your process is attached to. + +- **No third-party modules** — only the standard library +- **Linux, macOS, BSDs, and Windows** — one import, two files behind build tags +- **~100 lines of Go** — uses ioctl on Unix, `GetConsoleScreenBufferInfo` on Windows + +## Used by + +- Microsoft projects ([Azure/azure-dev](https://github.com/Azure/azure-dev)) +- AWS-related tooling ([awslabs/diagram-as-code](https://github.com/awslabs/diagram-as-code), [aws-cloudformation/rain](https://github.com/aws-cloudformation/rain)) +- **200+** public repositories + +## Why not `golang.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`. ## Install ```sh -$ go get github.com/nathan-fiscaletti/consolesize-go +go get github.com/nathan-fiscaletti/consolesize-go ``` ## Usage @@ -17,14 +33,59 @@ $ go get github.com/nathan-fiscaletti/consolesize-go package main import ( - "fmt" + "fmt" - "github.com/nathan-fiscaletti/consolesize-go" + "github.com/nathan-fiscaletti/consolesize-go" ) func main() { - cols, rows := consolesize.GetConsoleSize() - fmt.Printf("Rows: %v, Cols: %v\n", rows, cols) + cols, rows := consolesize.GetConsoleSize() + fmt.Printf("columns: %d, rows: %d\n", cols, rows) } ``` +`GetConsoleSize` returns **(columns, rows)**. + +## Binary size + +Minimal mains that only read terminal size are built side-by-side under [`sizecmp/`](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**. + +```sh +./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 +``` + +## Known projects using consolesize-go + +**Based on**: [network/dependents](https://github.com/nathan-fiscaletti/consolesize-go/network/dependents) as of April 6th, 2026. + +- [xo/usql](https://github.com/xo/usql) +- [TheZoraiz/ascii-image-converter](https://github.com/TheZoraiz/ascii-image-converter) +- [xyproto/algernon](https://github.com/xyproto/algernon) +- [neilotoole/sq](https://github.com/neilotoole/sq) +- [fwdcloudsec/granted](https://github.com/fwdcloudsec/granted) +- [awslabs/diagram-as-code](https://github.com/awslabs/diagram-as-code) +- [aws-cloudformation/rain](https://github.com/aws-cloudformation/rain) +- [xyproto/orbiton](https://github.com/xyproto/orbiton) +- [Azure/azure-dev](https://github.com/Azure/azure-dev) +- [pingcap/tiup](https://github.com/pingcap/tiup) +- [mondoohq/mql](https://github.com/mondoohq/mql) +- [common-fate/glide](https://github.com/common-fate/glide) +- [viamrobotics/rdk](https://github.com/viamrobotics/rdk) +- [xyproto/gendesk](https://github.com/xyproto/gendesk) +- [Isan-Rivkin/surf](https://github.com/Isan-Rivkin/surf) +- [arimatakao/mdx](https://github.com/arimatakao/mdx) +- [openshift/rosa](https://github.com/openshift/rosa) + +## License + +MIT — see [LICENSE](LICENSE). diff --git a/vendor/github.com/nathan-fiscaletti/consolesize-go/consolesize_unix.go b/vendor/github.com/nathan-fiscaletti/consolesize-go/consolesize_unix.go index fcec084e5e..7cfde4c811 100644 --- a/vendor/github.com/nathan-fiscaletti/consolesize-go/consolesize_unix.go +++ b/vendor/github.com/nathan-fiscaletti/consolesize-go/consolesize_unix.go @@ -1,4 +1,5 @@ -// +build unix, !windows +//go:build unix && !windows +// +build unix,!windows package consolesize diff --git a/vendor/github.com/nathan-fiscaletti/consolesize-go/consolesize_windows.go b/vendor/github.com/nathan-fiscaletti/consolesize-go/consolesize_windows.go index 51662aed93..b199e0a7d8 100644 --- a/vendor/github.com/nathan-fiscaletti/consolesize-go/consolesize_windows.go +++ b/vendor/github.com/nathan-fiscaletti/consolesize-go/consolesize_windows.go @@ -1,4 +1,5 @@ -// +build windows, !unix +//go:build windows && !unix +// +build windows,!unix package consolesize diff --git a/vendor/modules.txt b/vendor/modules.txt index 780d04e44e..c24b2fe133 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -354,8 +354,8 @@ github.com/mtibben/percent # github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 ## explicit github.com/munnerz/goautoneg -# github.com/nathan-fiscaletti/consolesize-go v0.0.0-20210105204122-a87d9f614b9d -## explicit +# github.com/nathan-fiscaletti/consolesize-go v0.0.0-20260406063853-3bac975de715 +## explicit; go 1.21 github.com/nathan-fiscaletti/consolesize-go # github.com/onsi/ginkgo/v2 v2.17.1 ## explicit; go 1.20