File tree Expand file tree Collapse file tree 2 files changed +3
-49
lines changed Expand file tree Collapse file tree 2 files changed +3
-49
lines changed Original file line number Diff line number Diff line change @@ -12,7 +12,6 @@ import (
1212 "reflect"
1313 "strconv"
1414 "strings"
15- "syscall"
1615 "time"
1716 "unicode"
1817
@@ -226,25 +225,9 @@ func isTTY(w io.Writer) bool {
226225 if w == forceColorWriter {
227226 return true
228227 }
229- // SyscallConn is safe during file close.
230- if sc , ok := w .(interface {
231- SyscallConn () (syscall.RawConn , error )
232- }); ok {
233- conn , err := sc .SyscallConn ()
234- if err != nil {
235- return false
236- }
237- var isTerm bool
238- err = conn .Control (func (fd uintptr ) {
239- isTerm = terminal .IsTerminal (int (fd ))
240- })
241- if err != nil {
242- return false
243- }
244- return isTerm
245- }
246- // Fallback to unsafe Fd.
247- f , ok := w .(interface { Fd () uintptr })
228+ f , ok := w .(interface {
229+ Fd () uintptr
230+ })
248231 return ok && terminal .IsTerminal (int (f .Fd ()))
249232}
250233
Original file line number Diff line number Diff line change 66 "flag"
77 "fmt"
88 "io"
9- "io/ioutil"
109 "os"
1110 "testing"
1211 "time"
@@ -179,34 +178,6 @@ func TestEntry(t *testing.T) {
179178 assert .Equal (t , "entry matches" , string (wantByt ), gotBuf .String ())
180179 })
181180 }
182-
183- t .Run ("isTTY during file close" , func (t * testing.T ) {
184- t .Parallel ()
185-
186- tmpdir := t .TempDir ()
187- f , err := ioutil .TempFile (tmpdir , "slog" )
188- if err != nil {
189- t .Fatal (err )
190- }
191- defer f .Close ()
192-
193- done := make (chan struct {}, 2 )
194- go func () {
195- entryhuman .Fmt (new (bytes.Buffer ), f , slog.SinkEntry {
196- Level : slog .LevelCritical ,
197- Fields : slog .M (
198- slog .F ("hey" , "hi" ),
199- ),
200- })
201- done <- struct {}{}
202- }()
203- go func () {
204- _ = f .Close ()
205- done <- struct {}{}
206- }()
207- <- done
208- <- done
209- })
210181}
211182
212183func BenchmarkFmt (b * testing.B ) {
You can’t perform that action at this time.
0 commit comments