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 UserRepositoryType = reflect.TypeOf((*UserRepository)(nil)) func init() { di.RegisterType(UserRepositoryType) } type UserRepository struct { annotation.TypeAnnotation `annotation:"@web:Repository(\"name\": \"/userDao\")"` Pool *pgxpool.Pool `annotation:"@Resource(\"name\": \"dbConnPool\")"` } func (ur *UserRepository) FindAll() { log.Printf("UserDao FindAll") conn, err := ur.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) } }