Gen allows generate fully-type-safe idiomatic Go code from Raw SQL, it uses annotations on interfaces, those interfaces could be applied to multiple models during code generation.
Not only your tuned SQL queries but also SQL snippets are allowed to be shared and reused, let’s take an example:
Raw SQL
type Querier interface { |
Run the above configuration program to generate the query interface codes for your application, and use the generated code like:
import "your_project/query" |
Code Snippets
Code Snippets are usually used with the DAO interface together
type Querier interface { |
Usage:
import "your_project/query" |
More control
Gen
support conditionally annotations and customize the returning results, refer Annotation to learn more