package user import ( "context" "log" "reflect" "git.loafle.net/loafer/annotation-go" "git.loafle.net/loafer/di-go" "github.com/jackc/pgx/v4/pgxpool" ) var UserDaoType = reflect.TypeOf((*UserDao)(nil)) func init() { di.RegisterType(UserDaoType) } type UserDao struct { annotation.TypeAnnotation `annotation:"@web:Dao(\"name\": \"/userDao\")"` Pool *pgxpool.Pool `annotation:"@Resource(\"name\": \"dbConnPool\")"` } func (ud *UserDao) FindAll() { log.Printf("UserDao FindAll") conn, err := ud.Pool.Acquire(context.Background()) if nil != err { log.Printf("%v", err) return } defer conn.Release() row, err := conn.Query(context.Background(), "select count(*) from users") if nil != err { log.Printf("%v", err) return } if row.Next() { var date int64 row.Scan(&date) log.Printf("%d", date) } }