Though we have refactoring tool to rename the struct field we do not have refactoring tool for deleting the struct field & its usages.
How to safely delete the struct field and its usages[Write & read access] across the files from any IDE that supports golang?
As far as I have seen none of the IDE(vim-go, intellij) supports this.
I had thought of deleting the struct field & run
go vet
which will return all error(along with line number) on every file & write a script to delete those lines but unfortunately vet stops reporting errors after very first error encountered in a file.
This is not something that could be fully automated. Let's say you remove the field
X
from the typePoint struct {X, Y int}
. What should the IDE do when it's used like this:Or like this:
What's needed is obviously not something the IDE could "guess".
To delete a struct field, delete it from the type definition and proceed to fix the compiler errors manually.