Refactor tty code into its own package

This commit is contained in:
Kovid Goyal
2022-08-22 21:20:54 +05:30
parent 13758e9600
commit 246277e7af
5 changed files with 24 additions and 19 deletions

View File

@@ -2,13 +2,26 @@ package utils
import (
"io"
"syscall"
"time"
"golang.org/x/sys/unix"
)
const (
DEFAULT_IO_BUFFER_SIZE = 8192
)
func NsecToTimespec(d time.Duration) unix.Timespec {
nv := syscall.NsecToTimespec(int64(d))
return unix.Timespec{Sec: nv.Sec, Nsec: nv.Nsec}
}
func NsecToTimeval(d time.Duration) unix.Timeval {
nv := syscall.NsecToTimeval(int64(d))
return unix.Timeval{Sec: nv.Sec, Usec: nv.Usec}
}
type BytesReader struct {
Data []byte
}