...

Source file src/github.com/go-kit/log/term/terminal_notwindows.go

Documentation: github.com/go-kit/log/term

     1  // Based on ssh/terminal:
     2  // Copyright 2011 The Go Authors. All rights reserved.
     3  // Use of this source code is governed by a BSD-style
     4  // license that can be found in the LICENSE file.
     5  
     6  //go:build (linux && !appengine) || darwin || freebsd || openbsd
     7  // +build linux,!appengine darwin freebsd openbsd
     8  
     9  package term
    10  
    11  import (
    12  	"io"
    13  	"syscall"
    14  	"unsafe"
    15  )
    16  
    17  // IsTerminal returns true if w writes to a terminal.
    18  func IsTerminal(w io.Writer) bool {
    19  	fw, ok := w.(fder)
    20  	if !ok {
    21  		return false
    22  	}
    23  	var termios syscall.Termios
    24  	_, _, err := syscall.Syscall6(syscall.SYS_IOCTL, fw.Fd(), ioctlReadTermios, uintptr(unsafe.Pointer(&termios)), 0, 0, 0)
    25  	return err == 0
    26  }
    27  

View as plain text