kmesh icon indicating copy to clipboard operation
kmesh copied to clipboard

golint warnings in ipsec_controller.go

Open mdimado opened this issue 8 months ago • 4 comments

What would you like to be added: golint warnings in ipsec_controller.go needs to be fixed:

Image

Why is this needed: to ensure the codebase follows Go best practices

mdimado avatar Aug 06 '25 19:08 mdimado

weired @mdimado can you also take a look at golangci-lint config, we used it in CI.

hzxuzhonghu avatar Aug 07 '25 07:08 hzxuzhonghu

hi @hzxuzhonghu it currently enables linters gofmt, goimports, govet, staticcheck, which i guess would catch common GO style and correctness. but it may not be catching all the issues in the IPsec controller code. and since I used golint, I have also listed the warnings encountered

mdimado avatar Aug 07 '25 18:08 mdimado

Image

@hzxuzhonghu encountered these 6 issues

mdimado avatar Aug 09 '25 02:08 mdimado

but, since golangci-lint only lints that file, without pulling in the rest of the package for type checking, the undefined issues arise also, the import errors are OS specific.

so, I ran the command golangci-lint run --build-tags=linux ./pkg/controller/encryption/ipsec and encountered these four issues:

Image

for the undefined: gomonkey issue,

the test file isn't getting compiled, so its symbols appear “undefined.”

and for the too many arguments in conversion to Controller error, the actual constructor is NewController and not Controller, so I fixed that

mdimado avatar Aug 09 '25 03:08 mdimado