I am working with Jetbrains GoLand and am wondering if its possible to somehow disable the auto removal of unused imports. I have searched the Jetbrains forums earlier and there is no such information for specifically for Goland. This picture shows the problem.
This feature is used so that you do not receive compilation errors for unused imports from Go.
While you can deactivate the feature via "Settings (Preferences) | Go | Imports | Optimize imports on the fly", my recommendation is to leave this as is and instead let the IDE manage the imports for you.
For example, you can start typing "template.New" inside the "main" function and the IDE will ask which "template" package to import as there are two packages in the standard library "text/template" and "html/template". When only one package is available, that will be imported automatically. When you will remove the last reference to the "template" package, the IDE will remove the import automatically, thus allowing you to run the code without any compilation issues.