Skip to content

Commit 9e54877

Browse files
committed
By default, just assume a tty
Use of cgo is a pain for cross-compilation, and also if the person running the build doesn't have a C compiler installed. So make the default version of `isatty.Isatty()` just return true. The only effect of this change is that progress information is output by default. If you want to really use `isatty()`, compile with make USE_ISATTY=t or go build --tags isatty Users can still control the output of progress information using `--progress`/`--no-progress`.
1 parent e19b4c7 commit 9e54877

File tree

3 files changed

+13
-0
lines changed

3 files changed

+13
-0
lines changed

Makefile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ GOFLAGS := \
1010
--tags "static" \
1111
-ldflags "-X main.BuildVersion=$(shell git rev-parse HEAD) -X main.BuildDescribe=$(shell git describe --tags --always --dirty)"
1212

13+
ifdef USE_ISATTY
14+
GOFLAGS := $(GOFLAGS) --tags isatty
15+
endif
16+
1317
GO_SRCS := $(shell cd $(GOPATH)/src/$(PACKAGE) && $(GO) list -f '{{$$ip := .ImportPath}}{{range .GoFiles}}{{printf ".gopath/src/%s/%s\n" $$ip .}}{{end}}{{range .CgoFiles}}{{printf ".gopath/src/%s/%s\n" $$ip .}}{{end}}{{range .TestGoFiles}}{{printf ".gopath/src/%s/%s\n" $$ip .}}{{end}}{{range .XTestGoFiles}}{{printf ".gopath/src/%s/%s\n" $$ip .}}{{end}}' ./...)
1418

1519
.PHONY: all

isatty/isatty_disabled.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// +build !isatty
2+
3+
package isatty
4+
5+
func Isatty(fd uintptr) (bool, error) {
6+
return true, nil
7+
}

isatty/isatty.go renamed to isatty/isatty_enabled.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// +build isatty
2+
13
package isatty
24

35
/*

0 commit comments

Comments
 (0)