package user import ( "context" "log" "reflect" "git.loafle.net/loafer/annotation-go" "git.loafle.net/loafer/di-go" "github.com/jackc/pgx/v4" ) var UserDaoType = reflect.TypeOf((*UserDao)(nil)) func init() { di.RegisterType(UserDaoType) } type UserDao struct { annotation.TypeAnnotation `annotation:"@web:Dao(\"name\": \"/userDao\")"` Conn *pgx.Conn `annotation:"@Resource(\"name\": \"dbConn\")"` } func (ud *UserDao) FindAll() { log.Printf("UserDao FindAll") row, err := ud.Conn.Query(context.Background(), "SELECT NOW()") if nil != err { log.Printf("%v", err) return } if row.Next() { var date string row.Scan(&date) log.Printf("%s", date) } }