Skip to content

Commit ae79a68

Browse files
author
Aleksei Vegner
committed
Add API and nolint comments
1 parent b72d6fd commit ae79a68

File tree

5 files changed

+15
-0
lines changed

5 files changed

+15
-0
lines changed

be.go

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
// +build mips mips64 ppc64 s390x
22

3+
//nolint:gochecknoglobals
34
package rfkill
45

56
import "encoding/binary"

example/main.go

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
//nolint:wsl,gochecknoglobals,gomnd
12
package main
23

34
import (

le.go

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
// +build !mips,!mips64,!ppc64,!s390x
22

3+
//nolint:gochecknoglobals
34
package rfkill
45

56
import "encoding/binary"

rfkill.go

+11
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import (
1212
"time"
1313
)
1414

15+
// List returns an accurate list of currently existing radio devices.
1516
//nolint:funlen
1617
func List(ctx context.Context) ([]*Device, error) {
1718
fd, err := openEventDev()
@@ -77,14 +78,17 @@ func List(ctx context.Context) ([]*Device, error) {
7778
}
7879
}
7980

81+
// Block blocks device(s) according to the given block option.
8082
func Block(option BlockOption) error {
8183
return block(1, option)
8284
}
8385

86+
// Unblock unblocks device(s) according to the given block option.
8487
func Unblock(option BlockOption) error {
8588
return block(0, option)
8689
}
8790

91+
// Events reports rfkill events until context is cancelled.
8892
func Events(ctx context.Context, pollInterval time.Duration, callback func(ev *Event)) error {
8993
fd, err := openEventDev()
9094
if err != nil {
@@ -163,6 +167,7 @@ func updateDevState(dev *Device, ev *rfkillEvent) {
163167
dev.SoftBlock = ev.Soft > 0
164168
}
165169

170+
// Device describes radio device.
166171
type Device struct {
167172
ID uint32
168173
Type RadioType
@@ -171,6 +176,7 @@ type Device struct {
171176
Name string
172177
}
173178

179+
// Event describes rfkill event.
174180
type Event struct {
175181
ID uint32
176182
Op EventOp
@@ -179,6 +185,7 @@ type Event struct {
179185
SoftBlock bool
180186
}
181187

188+
// RadioType is type for radio types.
182189
type RadioType uint8
183190

184191
const (
@@ -193,6 +200,7 @@ const (
193200
NFCRadio
194201
)
195202

203+
// EventOp is type for event operations.
196204
type EventOp uint8
197205

198206
const (
@@ -202,15 +210,18 @@ const (
202210
ChangeAllOp
203211
)
204212

213+
// BlockOption is type for block option.
205214
type BlockOption func(ev *rfkillEvent)
206215

216+
// WithID option sets device to block or unblock by ID
207217
func WithID(id uint) BlockOption {
208218
return func(ev *rfkillEvent) {
209219
ev.Op = uint8(ChangeOp)
210220
ev.ID = uint32(id)
211221
}
212222
}
213223

224+
// WithType option sets devices to block or unblock by type
214225
func WithType(typ RadioType) BlockOption {
215226
return func(ev *rfkillEvent) {
216227
ev.Op = uint8(ChangeAllOp)

rfkill_test.go

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
//nolint:wsl,gochecknoinits,gochecknoglobals,gomnd
12
package rfkill_test
23

34
import (

0 commit comments

Comments
 (0)