TLDR: Is there a way in golang (even if it is a bit non-standard), to "poison" a function or import of a certain package altogether.
The longer version: I am writing a thrift service, which all public facing functions return results, or an error of a certain type, declared in the thrift file. The code generator generates code for the interface like this:
publicFacingFunc(...) (returnType, error)
This would be great, until someone I am working with decides to check for another condition, and when that condition is not met does something like this:
if conditionIsNotMet {
return nil, errors.New(...)
}
The code compiles, but when the error arises, the received message is undocumented random string. So in these files, I want to prevent usage of "errors" and "fmt" packages.
And yes, I tried, and still have I a blaring warning at the top of the file, but nobody seems to read.
BTW, the public errors all have a respective "constructor", which is external to these files, and only those should be used, in my case.