github.com/samuelhorwitz/contract (go): Package contract is a design by contract implementation that intends to be unobtrusive and idiomatic. Contract attempts to make it easier to implement design by contract correctly, however it does not protect against abuse of the pattern.  Contract makes it easy to declare preconditions, postconditions and invariants. To fully and correctly implement this for a type, all public methods must make calls to In and Out or one of the alternative functions provided. The type must also implement the Invariable interface which requires an implemented Invariant method.  The Invariant method as well as the In and Out methods may not make any changes to state or otherwise cause any side-effects, although you will not be prevented from doing so. The only use for these calls should be for making assertions.  If instances of your type are mutable in ways that don't require entering through a public method, then you must ensure you include appropriate checks as needed, or restructure the code. This package cannot guarantee anything not already guaranteed by Go, it can only make it easier to follow the contract paradigm.  Assertions panic rather than return errors. This is because assertions are for validating that the software has not gone haywire, not performing business logic. Any expected states or arguments should _not_ be handled in the design by contract fashion. Design by contract is about failing fast, not about cleaning up expected, yet dirty, input.  By default, all assertions are included in the build. It seems nonsensical to use this library and then strip it out for production. The intended use is to ensure sanity in a production environment. However, some people seem to subscribe to a different view on this, so you may use the build tag "nodbc" to swap in no-op replacement functions.
Keywords: design-by-contract