// multiscan scans all DNS addresses returned for the host, returning the lowest grade
// and the concatenation of all the output.
13459
func multiscan(host string, scan func(string) (Grade, Output, error)) (grade Grade, output Output, err error) {
	domain, port, _ := net.SplitHostPort(host)
	var addrs []string
	addrs, err = net.LookupHost(domain)
	if err != nil {
		return
	}

	grade = Good
	out := make(map[string]Output)

	for _, addr := range addrs {
		var g Grade
		var o Output

		g, o, err = scan(net.JoinHostPort(addr, port))
		if err != nil {
			grade = Bad
			return
		}

		if g < grade {
			grade = g
		}

		out[addr] = o
	}
	output = out
	return
}
1068738
func (fa *Float64Array) Scan(value interface{}) (err error) {
	if value == nil {
		fa.Float64Array, fa.Valid = nil, false
		return
	}
	fa.Valid = true
	fa.Float64Array, err = Float64ArrayScan(value)
	return
}
601442
func (c *Client) Scan(indices ...string) *ScanService {
	builder := NewScanService(c)
	builder.Indices(indices...)
	return builder
}
121663
func (m *Machine) AllNetworkAddresses() ([]network.Address, error) {
	stateAddresses, err := m.AllAddresses()
	if err != nil {
		return nil, errors.Trace(err)
	}

	networkAddresses := make([]network.Address, len(stateAddresses))
	for i := range stateAddresses {
		networkAddresses[i] = stateAddresses[i].NetworkAddress()
	}
	// TODO(jam): 20161130 NetworkAddress object has a SpaceName attribute.
	// However, we are not filling in that information here.
	return networkAddresses, nil
}
32339
func (dst *Int8) Scan(src interface{}) error {
	if src == nil {
		*dst = Int8{Status: Null}
		return nil
	}

	switch src := src.(type) {
	case int64:
		*dst = Int8{Int: src, Status: Present}
		return nil
	case string:
		return dst.DecodeText(nil, []byte(src))
	case []byte:
		srcCopy := make([]byte, len(src))
		copy(srcCopy, src)
		return dst.DecodeText(nil, srcCopy)
	}

	return errors.Errorf("cannot scan %T", src)
}
742421
func NetworkHostPorts(hps []HostPort) []network.HostPort {
	nhps := make([]network.HostPort, len(hps))
	for i, hp := range hps {
		nhps[i] = hp.NetworkHostPort()
	}
	return nhps
}
592324
func scan(s string) <-chan match {
	ch := make(chan match)
	go func() {
		depth := 0
		opener := 0
		for index, char := range s {
			switch char {
			case '(':
				if depth == 0 {
					opener = index
				}
				depth++
			case ')':
				depth--
				if depth == 0 {
					ch <- match{
						openPos:  opener,
						closePos: index + 1,
					}
				}
			}

		}
		close(ch)
	}()
	return ch
}
851152
func (c *Connection) Scan(query interface{}, indexList []string, typeList []string, timeout string, size int) (*Response, error) {
	v := url.Values{}
	v.Add("search_type", "scan")
	v.Add("scroll", timeout)
	v.Add("size", strconv.Itoa(size))

	r := Request{
		Conn:      c,
		Query:     query,
		IndexList: indexList,
		TypeList:  typeList,
		method:    "POST",
		api:       "_search",
		ExtraArgs: v,
	}

	return r.Run()
}
973888
func (conn *Connection) DoScan(cmd string, args ...interface{}) (int, *ResultSet, error) {
	result, err := conn.Do(cmd, args...)
	if err != nil {
		return 0, nil, err
	}
	return result.Scanned()
}
1257056
func (t *Topology) Scan(value interface{}) error {
	switch v := value.(type) {
	case []byte:
		*t = Topology(v)
	case string:
		*t = Topology(v)
	case Topology:
		*t = v
	default:
		return errs.Errorf("failed to convert value of type %[1]T to topology: %[1]v", value)
	}
	return t.CheckValid()
}
624011
func (c *Connector) Scan(ctx context.Context, ei *dosa.EntityInfo, minimumFields []string, token string, limit int) ([]map[string]dosa.FieldValue, string, error) {
	return c.Range(ctx, ei, map[string][]*dosa.Condition{}, minimumFields, token, limit)
}
831210
func (inv *Investigate) RelatedDomains(domain string) ([]RelatedDomain, error) {
	var resp RelatedDomainList
	err := inv.GetParse(fmt.Sprintf(urls["related"], domain), &resp)
	if err != nil {
		return nil, err
	}
	return resp, nil
}
211453
func (i *Iterator) Scan(r Record) error {
	if err := i.rows.MapScan(r); err != nil {
		return err
	}

	mapBytesToString(r)

	return nil
}
158124
func (q *Query) Scan(dest ...interface{}) error {
	iter := q.Iter()
	if err := iter.checkErrAndNotFound(); err != nil {
		return err
	}
	iter.Scan(dest...)
	return iter.Close()
}
1279821
func (s SortIPAddrsByNetworkSize) Less(i, j int) bool {
	// Sort masks with a larger binary value (i.e. fewer hosts per network
	// prefix) after masks with a smaller value (larger number of hosts per
	// prefix).
	switch bytes.Compare([]byte(*s.IPAddrs[i].NetIPMask()), []byte(*s.IPAddrs[j].NetIPMask())) {
	case 0:
		// Fall through to the second test if the net.IPMasks are the
		// same.
		break
	case 1:
		return true
	case -1:
		return false
	default:
		panic("bad, m'kay?")
	}

	// Sort IPs based on the length (i.e. prefer IPv4 over IPv6).
	iLen := len(*s.IPAddrs[i].NetIP())
	jLen := len(*s.IPAddrs[j].NetIP())
	if iLen != jLen {
		return iLen > jLen
	}

	// Sort IPs based on their network address from lowest to highest.
	switch bytes.Compare(s.IPAddrs[i].NetIPNet().IP, s.IPAddrs[j].NetIPNet().IP) {
	case 0:
		break
	case 1:
		return false
	case -1:
		return true
	default:
		panic("lol wut?")
	}

	// If a host does not have a port set, it always sorts after hosts
	// that have a port (e.g. a host with a /32 and port number is more
	// specific and should sort first over a host with a /32 but no port
	// set).
	if s.IPAddrs[i].IPPort() == 0 || s.IPAddrs[j].IPPort() == 0 {
		return false
	}
	return s.IPAddrs[i].IPPort() < s.IPAddrs[j].IPPort()
}
21273
func (mls *MultiLineString) Scan(src interface{}) error {
	if src == nil {
		mls.MultiLineString = nil
		return nil
	}
	b, ok := src.([]byte)
	if !ok {
		return ErrExpectedByteSlice{Value: src}
	}
	got, err := Unmarshal(b)
	if err != nil {
		return err
	}
	mls1, ok := got.(*geom.MultiLineString)
	if !ok {
		return wkbcommon.ErrUnexpectedType{Got: mls1, Want: mls}
	}
	mls.MultiLineString = mls1
	return nil
}
832157
func Scan() ([]string, error) {
	var names []string
	dirEntries, err := ioutil.ReadDir(socketsPath)
	if err != nil && !os.IsNotExist(err) {
		return nil, errors.Wrap(err, "error reading dir entries")
	}

	for _, fi := range dirEntries {
		if fi.IsDir() {
			fi, err = os.Stat(filepath.Join(socketsPath, fi.Name(), fi.Name()+".sock"))
			if err != nil {
				continue
			}
		}

		if fi.Mode()&os.ModeSocket != 0 {
			names = append(names, strings.TrimSuffix(filepath.Base(fi.Name()), filepath.Ext(fi.Name())))
		}
	}

	for _, p := range specsPaths {
		dirEntries, err := ioutil.ReadDir(p)
		if err != nil && !os.IsNotExist(err) {
			return nil, errors.Wrap(err, "error reading dir entries")
		}

		for _, fi := range dirEntries {
			if fi.IsDir() {
				infos, err := ioutil.ReadDir(filepath.Join(p, fi.Name()))
				if err != nil {
					continue
				}

				for _, info := range infos {
					if strings.TrimSuffix(info.Name(), filepath.Ext(info.Name())) == fi.Name() {
						fi = info
						break
					}
				}
			}

			ext := filepath.Ext(fi.Name())
			switch ext {
			case ".spec", ".json":
				plugin := strings.TrimSuffix(fi.Name(), ext)
				names = append(names, plugin)
			default:
			}
		}
	}
	return names, nil
}