-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Description
Is your feature request related to a problem? Please describe.
unconvert supports -all flag but there is no way you can use it through golang-ci.
Describe the solution you'd like
It would be nice to run unconvert against multiple OSes.
Describe alternatives you've considered
Duplicate a method on Linux and FreeBSD build specific files.
Additional context
golang.org/x/sys/unix exports Statfs_t struct which has a Bavail field. Unfortunately, on FreeBSD it is int64 compared to uint64 on Linux.
Sample code that compiles on both platforms but produces the lint error on Linux:
pkg/storage/fs/ocis/ocis_unix.go:31:18: unnecessary conversion (unconvert)
bavail := uint64(unix.Statfs_t{}.Bavail)
I have followed these steps until I got stuck:
- Add Unconvert config to
pkg/config/config.go - Modify test file
test/testdata/unconvert.go - Pass config to unconvert in
pkg/golinters/unconvert.go - Modify unconvert to test against all platforms <-- stuck here
The problem is that unconvert builds loader.Program dynamically for each OS and architecture but golangci-lint passes its own loader.Program. How do I build the Program for other configurations?
On the other hand the up-to-date unconvert no longer uses loader.Program. Does it make sense to update the golangci-lint fork based on the latest changes?
UPD: Looking at the latest unconvert it should be much easier to support -all flag.