github.com/keybase/client/go@v0.0.0-20241007131713-f10651d043c8/logger/redirect_stderr_windows.go (about) 1 // Copyright 2016 Keybase, Inc. All rights reserved. Use of 2 // this source code is governed by the included BSD license. 3 4 package logger 5 6 import ( 7 "os" 8 "syscall" 9 ) 10 11 // yes, it is 32 bits... 12 const stderrHandle = int32(-12) 13 14 func tryRedirectStderrTo(f *os.File) (err error) { 15 var handle = stderrHandle 16 res, _, e1 := syscall.Syscall(procSetStdHandle.Addr(), 2, uintptr(handle), f.Fd(), 0) 17 if res != 0 { 18 err = error(e1) 19 } 20 return 21 } 22 23 var ( 24 procSetStdHandle = kernel32DLL.NewProc("SetStdHandle") 25 )