@@ -42,41 +42,39 @@ const (
42
42
netUnixStateDisconnected = 4
43
43
)
44
44
45
- // NetUnixType is the type of the type field.
46
- type NetUnixType uint64
45
+ // NetUNIXType is the type of the type field.
46
+ type NetUNIXType uint64
47
47
48
- // NetUnixFlags is the type of the flags field.
49
- type NetUnixFlags uint64
48
+ // NetUNIXFlags is the type of the flags field.
49
+ type NetUNIXFlags uint64
50
50
51
- // NetUnixState is the type of the state field.
52
- type NetUnixState uint64
51
+ // NetUNIXState is the type of the state field.
52
+ type NetUNIXState uint64
53
53
54
- // NetUnixLine represents a line of /proc/net/unix.
55
- type NetUnixLine struct {
54
+ // NetUNIXLine represents a line of /proc/net/unix.
55
+ type NetUNIXLine struct {
56
56
KernelPtr string
57
57
RefCount uint64
58
58
Protocol uint64
59
- Flags NetUnixFlags
60
- Type NetUnixType
61
- State NetUnixState
59
+ Flags NetUNIXFlags
60
+ Type NetUNIXType
61
+ State NetUNIXState
62
62
Inode uint64
63
63
Path string
64
64
}
65
65
66
- // NetUnix holds the data read from /proc/net/unix.
67
- type NetUnix struct {
68
- Rows []* NetUnixLine
66
+ // NetUNIX holds the data read from /proc/net/unix.
67
+ type NetUNIX struct {
68
+ Rows []* NetUNIXLine
69
69
}
70
70
71
- // NetUnix returns data read from /proc/net/unix.
72
- func (fs FS ) NetUnix () (* NetUnix , error ) {
73
- // TODO: this function name and type should be "NetUNIX" per Go convention.
74
- // Consider changing at a later time.
71
+ // NetUNIX returns data read from /proc/net/unix.
72
+ func (fs FS ) NetUNIX () (* NetUNIX , error ) {
75
73
return readNetUNIX (fs .proc .Path ("net/unix" ))
76
74
}
77
75
78
76
// readNetUNIX reads data in /proc/net/unix format from the specified file.
79
- func readNetUNIX (file string ) (* NetUnix , error ) {
77
+ func readNetUNIX (file string ) (* NetUNIX , error ) {
80
78
// This file could be quite large and a streaming read is desirable versus
81
79
// reading the entire contents at once.
82
80
f , err := os .Open (file )
@@ -89,7 +87,7 @@ func readNetUNIX(file string) (*NetUnix, error) {
89
87
}
90
88
91
89
// parseNetUNIX creates a NetUnix structure from the incoming stream.
92
- func parseNetUNIX (r io.Reader ) (* NetUnix , error ) {
90
+ func parseNetUNIX (r io.Reader ) (* NetUNIX , error ) {
93
91
// Begin scanning by checking for the existence of Inode.
94
92
s := bufio .NewScanner (r )
95
93
s .Scan ()
@@ -105,7 +103,7 @@ func parseNetUNIX(r io.Reader) (*NetUnix, error) {
105
103
minFields ++
106
104
}
107
105
108
- var nu NetUnix
106
+ var nu NetUNIX
109
107
for s .Scan () {
110
108
line := s .Text ()
111
109
item , err := nu .parseLine (line , hasInode , minFields )
@@ -123,7 +121,7 @@ func parseNetUNIX(r io.Reader) (*NetUnix, error) {
123
121
return & nu , nil
124
122
}
125
123
126
- func (u * NetUnix ) parseLine (line string , hasInode bool , min int ) (* NetUnixLine , error ) {
124
+ func (u * NetUNIX ) parseLine (line string , hasInode bool , min int ) (* NetUNIXLine , error ) {
127
125
fields := strings .Fields (line )
128
126
129
127
l := len (fields )
@@ -164,7 +162,7 @@ func (u *NetUnix) parseLine(line string, hasInode bool, min int) (*NetUnixLine,
164
162
}
165
163
}
166
164
167
- n := & NetUnixLine {
165
+ n := & NetUNIXLine {
168
166
KernelPtr : kernelPtr ,
169
167
RefCount : users ,
170
168
Type : typ ,
@@ -188,42 +186,42 @@ func (u *NetUnix) parseLine(line string, hasInode bool, min int) (*NetUnixLine,
188
186
return n , nil
189
187
}
190
188
191
- func (u NetUnix ) parseUsers (s string ) (uint64 , error ) {
189
+ func (u NetUNIX ) parseUsers (s string ) (uint64 , error ) {
192
190
return strconv .ParseUint (s , 16 , 32 )
193
191
}
194
192
195
- func (u NetUnix ) parseType (s string ) (NetUnixType , error ) {
193
+ func (u NetUNIX ) parseType (s string ) (NetUNIXType , error ) {
196
194
typ , err := strconv .ParseUint (s , 16 , 16 )
197
195
if err != nil {
198
196
return 0 , err
199
197
}
200
198
201
- return NetUnixType (typ ), nil
199
+ return NetUNIXType (typ ), nil
202
200
}
203
201
204
- func (u NetUnix ) parseFlags (s string ) (NetUnixFlags , error ) {
202
+ func (u NetUNIX ) parseFlags (s string ) (NetUNIXFlags , error ) {
205
203
flags , err := strconv .ParseUint (s , 16 , 32 )
206
204
if err != nil {
207
205
return 0 , err
208
206
}
209
207
210
- return NetUnixFlags (flags ), nil
208
+ return NetUNIXFlags (flags ), nil
211
209
}
212
210
213
- func (u NetUnix ) parseState (s string ) (NetUnixState , error ) {
211
+ func (u NetUNIX ) parseState (s string ) (NetUNIXState , error ) {
214
212
st , err := strconv .ParseInt (s , 16 , 8 )
215
213
if err != nil {
216
214
return 0 , err
217
215
}
218
216
219
- return NetUnixState (st ), nil
217
+ return NetUNIXState (st ), nil
220
218
}
221
219
222
- func (u NetUnix ) parseInode (s string ) (uint64 , error ) {
220
+ func (u NetUNIX ) parseInode (s string ) (uint64 , error ) {
223
221
return strconv .ParseUint (s , 10 , 64 )
224
222
}
225
223
226
- func (t NetUnixType ) String () string {
224
+ func (t NetUNIXType ) String () string {
227
225
switch t {
228
226
case netUnixTypeStream :
229
227
return "stream"
@@ -235,7 +233,7 @@ func (t NetUnixType) String() string {
235
233
return "unknown"
236
234
}
237
235
238
- func (f NetUnixFlags ) String () string {
236
+ func (f NetUNIXFlags ) String () string {
239
237
switch f {
240
238
case netUnixFlagListen :
241
239
return "listen"
@@ -244,7 +242,7 @@ func (f NetUnixFlags) String() string {
244
242
}
245
243
}
246
244
247
- func (s NetUnixState ) String () string {
245
+ func (s NetUNIXState ) String () string {
248
246
switch s {
249
247
case netUnixStateUnconnected :
250
248
return "unconnected"
0 commit comments