//ReadList read for []struct
773099
func ReadList(file string, isGbk bool, out interface{}) (err error) {
	//catch panic
	defer func() {
		if rerr := recover(); rerr != nil {
			err = errors.New(fmt.Sprintf("read csv file: %v, error: %v", file, rerr))
		}
	}()

	if out == nil {
		return errors.New("Cannot remake from <nil>")
	}

	outv := reflect.ValueOf(out)

	outt := outv.Type()
	outk := outt.Kind()

	if outk != reflect.Ptr {
		return errors.New("Cannot reflect into non-pointer")
	}
	slicev := outv.Elem()
	slicet := slicev.Type()
	slicek := slicev.Kind()

	if slicek != reflect.Slice {
		return errors.New("Pointer must point to a slice")
	}

	elmt := slicet.Elem()
	elmIsPtr := false
	//element is ptr
	if elmt.Kind() == reflect.Ptr{
		elmt = elmt.Elem()
		elmIsPtr = true
	}

	//map field => value
	idxs := make(map[string]int)

	for i := 0; i < elmt.NumField(); i++ {
		name := elmt.Field(i).Tag.Get("csv")
		if len(name) <= 0 {
			name = elmt.Field(i).Name
		}
		idxs[format(name)] = i
	}

	err = ReadRaw(file, isGbk, func(fields []Field) error {
		elmv := reflect.Indirect(reflect.New(elmt))
		for _, f := range fields {
			if len(f.Name) <= 0 {
				continue
			}
			idx, ok := idxs[format(f.Name)]
			if !ok {
				continue
			}
			fValue := elmv.Field(idx)
			setValue(&fValue, f)
		}
		if elmIsPtr{
			slicev.Set(reflect.Append(slicev, elmv.Addr()))
		}else{
			slicev.Set(reflect.Append(slicev, elmv))
		}
		return nil
	})

	return err
}
578861
func (b ShapeValueBuilder) BuildList(name, memName string, ref *ShapeRef, v []interface{}) string {
	ret := ""

	if len(v) == 0 || ref == nil {
		return ""
	}

	passRef := &ref.Shape.MemberRef
	ret += fmt.Sprintf("%s: %s {\n", memName, b.GoType(ref, false))
	ret += b.buildListElements(passRef, v)
	ret += "},\n"
	return ret
}
1241201
func readArray(rd *bufio.Reader) ([]string, error) {
	line, err := rd.ReadString('\n')
	if err != nil {
		return nil, err
	}
	if len(line) < 3 {
		return nil, ErrProtocol
	}

	switch line[0] {
	default:
		return nil, ErrProtocol
	case '*':
		l, err := strconv.Atoi(line[1 : len(line)-2])
		if err != nil {
			return nil, err
		}
		// l can be -1
		var fields []string
		for ; l > 0; l-- {
			s, err := readString(rd)
			if err != nil {
				return nil, err
			}
			fields = append(fields, s)
		}
		return fields, nil
	}
}
831435
func (rf *requireFile) GetList(extInfo *types.ExtensionInfo) ([]string, int64, error) {
	assetPath, _, err := resolvePath(extInfo, rf.Path, rf.BaseDir)
	if err != nil {
		return nil, 0, err
	}
	f, err := os.Stat(assetPath)
	if err != nil {
		return nil, 0, err
	}
	return []string{assetPath}, f.ModTime().Unix(), nil
}
1324852
func List(c *messagebird.Client) (*HLRList, error) {
	hlrList := &HLRList{}
	if err := c.Request(hlrList, http.MethodGet, path, nil); err != nil {
		return nil, err
	}

	return hlrList, nil
}
722274
func (env *Env) ReaderList(fn func(string) error) error {
	ctx, done := newMsgFunc(fn)
	defer done()
	if fn == nil {
		ctx = 0
	}

	ret := C.lmdbgo_mdb_reader_list(env._env, C.size_t(ctx))
	if ret >= 0 {
		return nil
	}
	if ret < 0 && ctx != 0 {
		err := ctx.get().err
		if err != nil {
			return err
		}
	}
	return operrno("mdb_reader_list", ret)
}
958403
func (o *querySet) ValuesList(results *[]ParamsList, exprs ...string) (int64, error) {
	return o.orm.alias.DbBaser.ReadValues(o.orm.db, o, o.mi, o.cond, exprs, results, o.orm.alias.TZ)
}
73006
func (d *DeviceMapperDriver) List() (result []string) {
	md := d.MetadataDir()
	if files, err := ioutil.ReadDir(md); err != nil {
		glog.Errorf("Error trying to read from metadata directory: %s", md)
		return
	} else {
		for _, fi := range files {
			if fi.IsDir() {
				result = append(result, fi.Name())
			}
		}
	}
	return
}
430362
func ReadLines(path string) ([]string, error) {
	f, err := os.Open(path)
	if err != nil {
		return nil, err
	}
	defer f.Close()

	var lines []string
	scanner := bufio.NewScanner(f)
	line := ""
	for scanner.Scan() {
		l := strings.TrimSpace(scanner.Text())
		if len(l) == 0 || strings.Index(l, "#") == 0 {
			continue
		}
		line += " " + l
		if l[len(l)-1:] == ";" {
			lines = append(lines, strings.TrimSpace(line))
			line = ""
		}
	}
	if line != "" {
		lines = append(lines, strings.TrimSpace(line))
	}
	return lines, scanner.Err()
}
577427
func (f *freelist) read(p *page) {
	// If the page.count is at the max uint16 value (64k) then it's considered
	// an overflow and the size of the freelist is stored as the first element.
	idx, count := 0, int(p.count)
	if count == 0xFFFF {
		idx = 1
		count = int(((*[maxAllocSize]pgid)(unsafe.Pointer(&p.ptr)))[0])
	}

	// Copy the list of page ids from the freelist.
	if count == 0 {
		f.ids = nil
	} else {
		ids := ((*[maxAllocSize]pgid)(unsafe.Pointer(&p.ptr)))[idx:count]
		f.ids = make([]pgid, len(ids))
		copy(f.ids, ids)

		// Make sure they're sorted.
		sort.Sort(pgids(f.ids))
	}

	// Rebuild the page cache.
	f.reindex()
}
699204
func (o *rawSet) ValuesList(container *[]ParamsList, cols ...string) (int64, error) {
	return o.readValues(container, cols)
}
174944
func (w *Writer) WriteList(lst *list.List) {
	ptr := unsafe.Pointer(lst)
	typ := reflect.TypeOf(lst)
	if writeRef(w, ptr, typ) {
		return
	}
	setWriterRef(w, ptr, typ)
	count := lst.Len()
	if count == 0 {
		writeEmptyList(w)
		return
	}
	writeListHeader(w, count)
	for e := lst.Front(); e != nil; e = e.Next() {
		w.Serialize(e.Value)
	}
	writeListFooter(w)
}
1168262
func (c SimpleFSClient) SimpleFSReadList(ctx context.Context, opID OpID) (res SimpleFSListResult, err error) {
	__arg := SimpleFSReadListArg{OpID: opID}
	err = c.Cli.Call(ctx, "keybase.1.SimpleFS.simpleFSReadList", []interface{}{__arg}, &res)
	return
}
1297064
func parseHeaderList(headerList string) []string {
	l := len(headerList)
	h := make([]byte, 0, l)
	upper := true
	// Estimate the number headers in order to allocate the right splice size
	t := 0
	for i := 0; i < l; i++ {
		if headerList[i] == ',' {
			t++
		}
	}
	headers := make([]string, 0, t)
	for i := 0; i < l; i++ {
		b := headerList[i]
		if b >= 'a' && b <= 'z' {
			if upper {
				h = append(h, b-toLower)
			} else {
				h = append(h, b)
			}
		} else if b >= 'A' && b <= 'Z' {
			if !upper {
				h = append(h, b+toLower)
			} else {
				h = append(h, b)
			}
		} else if b == '-' || b == '_' || (b >= '0' && b <= '9') {
			h = append(h, b)
		}

		if b == ' ' || b == ',' || i == l-1 {
			if len(h) > 0 {
				// Flush the found header
				headers = append(headers, string(h))
				h = h[:0]
				upper = true
			}
		} else {
			upper = b == '-' || b == '_'
		}
	}
	return headers
}
896463
func (p *Parser) parseStringList() ([]string, error) {
	// Parse first (required) string.
	str, err := p.parseString()
	if err != nil {
		return nil, err
	}
	strs := []string{str}

	// Parse remaining (optional) strings.
	for {
		if tok, _, _ := p.ScanIgnoreWhitespace(); tok != COMMA {
			p.Unscan()
			return strs, nil
		}

		if str, err = p.parseString(); err != nil {
			return nil, err
		}

		strs = append(strs, str)
	}
}
1314710
func (c *Client) List(args ...string) ([]string, error) {
	id, err := c.cmd("list " + quoteArgs(args))
	if err != nil {
		return nil, err
	}
	c.text.StartResponse(id)
	defer c.text.EndResponse(id)

	var ret []string
	for {
		line, err := c.text.ReadLine()
		if err != nil {
			return nil, err
		}

		i := strings.Index(line, ": ")
		if i > 0 {
			ret = append(ret, line[i+2:])
		} else if line == "OK" {
			break
		} else {
			return nil, textproto.ProtocolError("can't parse line: " + line)
		}
	}
	return ret, nil
}
1157208
func List() ([]string, error) {
	godelw, err := newGodelwRunner()
	if err != nil {
		return nil, err
	}
	products, err := godelw.run("products")
	if err != nil {
		return nil, err
	}
	return strings.Split(products, "\n"), nil
}