github.com/qioalice/ekago/v3@v3.3.2-0.20221202205325-5c262d586ee4/internal/ekasys/os_std_sync_private.go (about) 1 // Copyright © 2021. All rights reserved. 2 // Author: Ilya Stroy. 3 // Contacts: iyuryevich@pm.me, https://github.com/qioalice 4 // License: https://opensource.org/licenses/MIT 5 6 package ekasys 7 8 import ( 9 "os" 10 "sync" 11 ) 12 13 type ( 14 stdSynced struct { 15 f *os.File 16 sync.Mutex 17 } 18 ) 19 20 var ( 21 Stdout *stdSynced 22 ) 23 24 func (ss *stdSynced) Write(b []byte) (n int, err error) { 25 ss.Lock() 26 n, err = ss.f.Write(b) 27 ss.Unlock() 28 return n, err 29 } 30 31 func initStdoutSynced() { 32 Stdout = new(stdSynced) 33 Stdout.f = os.Stdout 34 }