Skip to content

Commit fe19450

Browse files
authored
Merge pull request #709 from hj-johannes-lee/govet-fieldalignment
Add govet-fieldalignment linter check
2 parents 32e8c59 + 8fc5df7 commit fe19450

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+147
-139
lines changed

.golangci.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@ linters-settings:
4848
min-confidence: 0.9
4949
govet:
5050
check-shadowing: true
51+
enable:
52+
- "fieldalignment"
5153
gocyclo:
5254
min-complexity: 15
5355
gocognit:

cmd/fpga_crihook/main.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,8 @@ type newPortFun func(string) (fpga.Port, error)
6060

6161
// Device defines structure for Config.Linux.Devices entries.
6262
type Device struct {
63-
// these fields are set by the hook
64-
name string
65-
processed bool
63+
// this field is set by the hook
64+
name string
6665

6766
// these are set by JSON decoder
6867
Path string `json:"path"`
@@ -71,6 +70,9 @@ type Device struct {
7170
Minor int `json:"minor"`
7271
UID int `json:"uid"`
7372
GID int `json:"gid"`
73+
74+
// this field is set by the hook
75+
processed bool
7476
}
7577

7678
func (dev *Device) getName() string {
@@ -87,9 +89,9 @@ func decodeJSONStream(reader io.Reader, dest interface{}) error {
8789
}
8890

8991
type hookEnv struct {
92+
newPort newPortFun
9093
bitstreamDir string
9194
config string
92-
newPort newPortFun
9395
}
9496

9597
type fpgaParams struct {

cmd/fpga_crihook/main_test.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -179,9 +179,9 @@ func TestGetConfig(t *testing.T) {
179179
// testFpgaPort represent Fake FPGA Port device for testing purposes.
180180
type testFpgaPort struct {
181181
fpga.Port
182-
callNo int
183182
interfaceUUIDS []string
184183
accelTypeUUIDS []string
184+
callNo int
185185
failProgramming bool
186186
}
187187

@@ -229,12 +229,12 @@ func TestGetFPGAParams(t *testing.T) {
229229
stdinJSON string
230230
configJSON string
231231
afuIDPath string
232-
sysfsdirs []string
233-
sysfsfiles map[string][]byte
234-
expectedErr bool
235232
expectedRegion string
236233
expectedAFU string
237234
expectedPortDevice string
235+
sysfsfiles map[string][]byte
236+
sysfsdirs []string
237+
expectedErr bool
238238
}{
239239
{
240240
name: "valid setup",
@@ -343,9 +343,9 @@ func TestProcess(t *testing.T) {
343343
name string
344344
stdinJSON string
345345
configJSON string
346-
sysfsdirs []string
347-
sysfsfiles map[string][]byte
348346
newPort newPortFun
347+
sysfsfiles map[string][]byte
348+
sysfsdirs []string
349349
expectedErr bool
350350
}{
351351
{

cmd/fpga_plugin/dfl_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -315,13 +315,13 @@ func TestScanFPGAsDFL(t *testing.T) {
315315
sysfs := path.Join(tmpdir, "sys")
316316
dev := path.Join(tmpdir, "dev")
317317
tcases := []struct {
318-
name string
319-
mode string
320-
devs []string
321318
sysfsdirs []string
322319
sysfsfiles map[string][]byte
323320
newPort newPortFunc
324321
expectedDevTreeKeys map[string][]string
322+
name string
323+
mode string
324+
devs []string
325325
}{
326326
{
327327
name: "Valid DFL scan in af mode",

cmd/fpga_plugin/fpga_plugin.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -174,10 +174,10 @@ type devicePlugin struct {
174174
getDevTree getDevTreeFunc
175175
newPort newPortFunc
176176

177-
annotationValue string
178-
179177
scanTicker *time.Ticker
180178
scanDone chan bool
179+
180+
annotationValue string
181181
}
182182

183183
// newDevicePlugin returns new instance of devicePlugin.

cmd/fpga_plugin/fpga_plugin_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -191,12 +191,12 @@ func TestScan(t *testing.T) {
191191
dev := path.Join(root, "dev")
192192

193193
tcases := []struct {
194-
name string
195-
mode string
196-
devs []string
197194
sysfsdirs []string
198195
sysfsfiles map[string][]byte
199196
newPort newPortFunc
197+
name string
198+
mode string
199+
devs []string
200200
}{
201201
{
202202
name: "valid OPAE scan in af mode",

cmd/fpga_plugin/opae_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -267,13 +267,13 @@ func TestScanFPGAsOPAE(t *testing.T) {
267267
sysfs := path.Join(tmpdir, "sys")
268268
dev := path.Join(tmpdir, "dev")
269269
tcases := []struct {
270-
name string
271-
mode string
272-
devs []string
273270
sysfsdirs []string
274271
sysfsfiles map[string][]byte
275272
newPort newPortFunc
276273
expectedDevTreeKeys map[string][]string
274+
name string
275+
mode string
276+
devs []string
277277
}{
278278
{
279279
name: "Valid OPAE scan in af mode",

cmd/gpu_nfdhook/labeler.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,12 @@ const (
4444
type labelMap map[string]string
4545

4646
type labeler struct {
47-
sysfsDRMDir string
48-
debugfsDRIDir string
49-
5047
gpuDeviceReg *regexp.Regexp
5148
controlDeviceReg *regexp.Regexp
5249
labels labelMap
50+
51+
sysfsDRMDir string
52+
debugfsDRIDir string
5353
}
5454

5555
func newLabeler(sysfsDRMDir, debugfsDRIDir string) *labeler {

cmd/gpu_nfdhook/labeler_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,14 @@ import (
2323
)
2424

2525
type testcase struct {
26-
sysfsdirs []string
27-
sysfsfiles map[string][]byte
28-
name string
29-
memoryOverride uint64
30-
memoryReserved uint64
3126
capabilityFile map[string][]byte
3227
expectedRetval error
3328
expectedLabels labelMap
29+
name string
30+
sysfsfiles map[string][]byte
31+
sysfsdirs []string
32+
memoryOverride uint64
33+
memoryReserved uint64
3434
}
3535

3636
//nolint:funlen

cmd/gpu_plugin/gpu_plugin.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,18 +59,18 @@ type cliOptions struct {
5959
}
6060

6161
type devicePlugin struct {
62-
sysfsDir string
63-
devfsDir string
64-
65-
options cliOptions
66-
6762
gpuDeviceReg *regexp.Regexp
6863
controlDeviceReg *regexp.Regexp
6964

7065
scanTicker *time.Ticker
7166
scanDone chan bool
7267

7368
resMan rm.ResourceManager
69+
70+
sysfsDir string
71+
devfsDir string
72+
73+
options cliOptions
7474
}
7575

7676
func newDevicePlugin(sysfsDir, devfsDir string, options cliOptions) *devicePlugin {

0 commit comments

Comments
 (0)