예제 #1
0
파일: pq.go 프로젝트: dvarrazzo/pger
func columns(r *PgRows) []string {
	nfields := int(C.PQnfields(r.result))
	rv := make([]string, nfields)
	for i := 0; i < nfields; i++ {
		rv[i] = C.GoString(C.PQfname(r.result, C.int(i)))
	}
	return rv
}
예제 #2
0
func (r *driverRows) Columns() []string {
	if r.cols == nil {
		r.cols = make([]string, r.ncols)
		for i := 0; i < r.ncols; i++ {
			r.cols[i] = C.GoString(C.PQfname(r.res, C.int(i)))
		}
	}
	return r.cols
}
예제 #3
0
// Names returns the list of column (field) names, in order, in the result.
func (r *Result) Names() []string {
	if r.cols == nil {
		r.cols = make([]string, r.ncols)
		for i := 0; i < r.ncols; i++ {
			r.cols[i] = C.GoString(C.PQfname(r.res, C.int(i)))
		}
	}
	return r.cols
}