/
os.go
67 lines (54 loc) · 1.26 KB
/
os.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
// Copyright(C) 2020 github.com/hidu All Rights Reserved.
// Author: hidu (duv123+git@baidu.com)
// Date: 2020/12/20
package gocore
import (
"os"
"time"
)
// SetDeadline can set deadline
type SetDeadline interface {
SetDeadline(t time.Time) error
}
// SetReadDeadline can set readDeadline
type SetReadDeadline interface {
SetReadDeadline(t time.Time) error
}
// SetWriteDeadline can set writeDeadline
type SetWriteDeadline interface {
SetWriteDeadline(t time.Time) error
}
// SetReadWriteDeadline can set read and write deadline
type SetReadWriteDeadline interface {
SetReadDeadline(t time.Time) error
SetWriteDeadline(t time.Time) error
}
// OsProcess interface of *os.Process
type OsProcess interface {
Kill() error
Release() error
Signal(sig os.Signal) error
Wait() (*os.ProcessState, error)
}
var _ OsProcess = (*os.Process)(nil)
// OsProcessState interface of *os.ProcessState
type OsProcessState interface {
ExitCode() int
Exited() bool
Pid() int
String() string
Success() bool
Sys() interface{}
SysUsage() interface{}
SystemTime() time.Duration
UserTime() time.Duration
}
var _ OsProcessState = (*os.ProcessState)(nil)
// Kill kill
type Kill interface {
Kill() error
}
var _ OsFile = (*os.File)(nil)
type FileInfo interface {
FileInfo() os.FileInfo
}