// --------------------------
192222
func isEmptyValue(v reflect.Value, tinfos *TypeInfos, deref, checkStruct bool) bool {
	urv := (*unsafeReflectValue)(unsafe.Pointer(&v))
	if urv.flag == 0 {
		return true
	}
	switch v.Kind() {
	case reflect.Invalid:
		return true
	case reflect.String:
		return (*unsafeString)(urv.ptr).Len == 0
	case reflect.Slice:
		return (*unsafeSlice)(urv.ptr).Len == 0
	case reflect.Bool:
		return !*(*bool)(urv.ptr)
	case reflect.Int:
		return *(*int)(urv.ptr) == 0
	case reflect.Int8:
		return *(*int8)(urv.ptr) == 0
	case reflect.Int16:
		return *(*int16)(urv.ptr) == 0
	case reflect.Int32:
		return *(*int32)(urv.ptr) == 0
	case reflect.Int64:
		return *(*int64)(urv.ptr) == 0
	case reflect.Uint:
		return *(*uint)(urv.ptr) == 0
	case reflect.Uint8:
		return *(*uint8)(urv.ptr) == 0
	case reflect.Uint16:
		return *(*uint16)(urv.ptr) == 0
	case reflect.Uint32:
		return *(*uint32)(urv.ptr) == 0
	case reflect.Uint64:
		return *(*uint64)(urv.ptr) == 0
	case reflect.Uintptr:
		return *(*uintptr)(urv.ptr) == 0
	case reflect.Float32:
		return *(*float32)(urv.ptr) == 0
	case reflect.Float64:
		return *(*float64)(urv.ptr) == 0
	case reflect.Interface:
		isnil := urv.ptr == nil || *(*unsafe.Pointer)(urv.ptr) == nil
		if deref {
			if isnil {
				return true
			}
			return isEmptyValue(v.Elem(), tinfos, deref, checkStruct)
		}
		return isnil
	case reflect.Ptr:
		// isnil := urv.ptr == nil (not sufficient, as a pointer value encodes the type)
		isnil := urv.ptr == nil || *(*unsafe.Pointer)(urv.ptr) == nil
		if deref {
			if isnil {
				return true
			}
			return isEmptyValue(v.Elem(), tinfos, deref, checkStruct)
		}
		return isnil
	case reflect.Struct:
		return isEmptyStruct(v, tinfos, deref, checkStruct)
	case reflect.Map, reflect.Array, reflect.Chan:
		return v.Len() == 0
	}
	return false
}
219947
func (ListInstanceGroups) Each(resp interface{}, callback IterateItemFunc) {
	items, ok := resp.(*ListInstanceGroupsResponse)
	if !ok {
		callback(nil, fmt.Errorf("wrong type, ListInstanceGroupsResponse was expected, got %T", resp))
		return
	}

	for i := range items.InstanceGroup {
		if !callback(&items.InstanceGroup[i], nil) {
			break
		}
	}
}
66313
func init() {
	pc, _, _, ok := runtime.Caller(0)
	if !ok {
		return
	}
	f := runtime.FuncForPC(pc)
	if f == nil {
		return
	}
	thisPackage = f.Name()
	x := strings.LastIndex(thisPackage, "/")
	if x < 0 {
		return
	}
	y := strings.Index(thisPackage[x:], ".")
	if y < 0 {
		return
	}
	// thisPackage includes the trailing . after the package name.
	thisPackage = thisPackage[:x+y+1]
}
737568
func (s *LoadBalancerService) GetLoadBalancerByName(name string, opts ...OptionFunc) (*LoadBalancer, int, error) {
	id, count, err := s.GetLoadBalancerID(name, opts...)
	if err != nil {
		return nil, count, err
	}

	r, count, err := s.GetLoadBalancerByID(id, opts...)
	if err != nil {
		return nil, count, err
	}
	return r, count, nil
}
1186348
func (ini *INI) SectionGetBool(section, key string) (bool, bool) {
    v, ok := ini.SectionGet(section, key)
    if ok {
        switch v {
        case "1", "t", "T", "true", "TRUE", "True", "on", "ON", "On", "yes", "YES", "Yes":
            return true, true
        case "0", "f", "F", "false", "FALSE", "False", "off", "OFF", "Off", "no", "NO", "No":
            return false, true
        }
    }

    return false, false
}
927872
func (ListOSCategories) Each(resp interface{}, callback IterateItemFunc) {
	items, ok := resp.(*ListOSCategoriesResponse)
	if !ok {
		callback(nil, fmt.Errorf("wrong type, ListOSCategoriesResponse was expected, got %T", resp))
		return
	}

	for i := range items.OSCategory {
		if !callback(&items.OSCategory[i], nil) {
			break
		}
	}
}
869505
func (m Message) IsMentionFor(user string) bool {
	return strings.HasPrefix(m.Message, "<@"+user+">")
}
907623
func (r *Lexer) Interface() interface{} {
	if r.token.kind == tokenUndef && r.Ok() {
		r.FetchToken()
	}

	if !r.Ok() {
		return nil
	}
	switch r.token.kind {
	case tokenString:
		return r.String()
	case tokenNumber:
		return r.Float64()
	case tokenBool:
		return r.Bool()
	case tokenNull:
		r.Null()
		return nil
	}

	if r.token.delimValue == '{' {
		r.consume()

		ret := map[string]interface{}{}
		for !r.IsDelim('}') {
			key := r.String()
			r.WantColon()
			ret[key] = r.Interface()
			r.WantComma()
		}
		r.Delim('}')

		if r.Ok() {
			return ret
		} else {
			return nil
		}
	} else if r.token.delimValue == '[' {
		r.consume()

		var ret []interface{}
		for !r.IsDelim(']') {
			ret = append(ret, r.Interface())
			r.WantComma()
		}
		r.Delim(']')

		if r.Ok() {
			return ret
		} else {
			return nil
		}
	}
	r.errSyntax()
	return nil
}
781861
func For(msg string, timeout, interval time.Duration, f func() (bool, error)) error {
	log.Infof("Wait for %s [timeout: %s, interval: %s]", msg, timeout, interval)

	var lastErr string
	timeUp := time.After(timeout)
	for {
		select {
		case <-timeUp:
			return fmt.Errorf("time limit exceeded: last error: %s", lastErr)
		default:
		}

		stop, err := f()
		if stop {
			return nil
		}
		if err != nil {
			lastErr = err.Error()
		}

		time.Sleep(interval)
	}
}
791269
func (s *i18nSorter) Less(i, j int) bool {

	iValue := strings.ToLower(s.getComparisonValueFunc(s.toBeSorted[i]))
	jValue := strings.ToLower(s.getComparisonValueFunc(s.toBeSorted[j]))

	// if it's a local sort, use the collator
	if s.collator != nil {
		return s.collator.CompareString(iValue, jValue) == -1
	}

	// for universal sorts, normalize the unicode to sort
	normalizer := norm.NFKD
	iValue = normalizer.String(iValue)
	jValue = normalizer.String(jValue)

	return bytes.Compare([]byte(iValue), []byte(jValue)) == -1
}
831996
func main() {

	// init a connection
	s, err := solr.Init("localhost", 8983, "collection-name")

	if err != nil {
		fmt.Println(err)
		return
	}

	// define a solr query string
	q := "q=*:*"

	// perform a query    
	res, err := s.SelectRaw(q)

	if err != nil {
		fmt.Println(err)
		return
	}

	// grab results for ease of use later on
	results := res.Results

	// print a summary and loop over results, priting the "title" and "latlng" fields
	fmt.Println(
		fmt.Sprintf("Query: %#v\nHits: %d\nNum Results: %d\nQtime: %d\nStatus: %d\n\nResults\n-------\n",
			q,
			results.NumFound,
			results.Len(),
			res.QTime,
			res.Status))

	for i := 0; i < results.Len(); i++ {
		fmt.Println("Some field:", results.Get(i).Field("id"))
		fmt.Println("Some other field:", results.Get(i).Field("title"))

		fmt.Println("")
	}

}
410040
func (list *DefinitionList) parseAndAppendString(text string) {
	emptyLineRE := regexp.MustCompile("^[[:space:]]*$")
	depthRE := regexp.MustCompile("^( *)(.*)")

	startDefRE := regexp.MustCompile("^ *- (.*)")
	keyedDefRE := regexp.MustCompile("^([^:]+):[[:space:]]*(.*)")

	descTextRE := regexp.MustCompile("(?sUm:^(.*) *-)")

	var (
		currentList  *DefinitionList
		currentItem  *Definition
		currentDepth int
	)

	descMatch := descTextRE.FindStringSubmatch(text)
	if len(descMatch) > 1 {
		list.desc = descMatch[1]
		text = text[len(descMatch[1]):]
	}

	currentList = list

	for lineNo, line := range strings.Split(text, "\n") {
		// nesting depth == nr. of indentation spaces
		if emptyLineRE.MatchString(line) {
			continue
		}
		newDepth := len(depthRE.ReplaceAllString(line, "$1"))

		if startDefRE.MatchString(line) {
			// Start new definition
			start := startDefRE.ReplaceAllString(line, "$1")

			newItem := &Definition{}
			if keyedDefRE.MatchString(start) {
				newItem.name = keyedDefRE.ReplaceAllString(start, "$1")
				newItem.desc = keyedDefRE.ReplaceAllString(start, "$2") + "\n"

			} else {
				newItem.name = ""
				newItem.desc = start + "\n"
			}

			if newDepth == currentDepth {
				// Keep current nesting level
				if currentItem != nil {
					newItem.parent = currentItem.parent
				}

			} else if newDepth > currentDepth {
				// Dive deeper
				newItem.parent = currentItem
				currentItem.children = DefinitionList{}
				currentList = &currentItem.children

			} else if newDepth < currentDepth {
				// One up
				if currentItem.parent.parent != nil {
					currentList = &currentItem.parent.parent.children
				} else {
					currentList = list
				}
			}

			currentList.add(newItem)
			currentItem = newItem
			currentDepth = newDepth

		} else if currentItem == nil {
			// Parse error
			panic(fmt.Sprintf("Comment line %d: Parse error: currentItem == nil "+
				"near \"%s\" (plain paragraphs mixed with definition list?)\n", lineNo, line))

		} else if newDepth != currentDepth {
			// Parse error
			panic(fmt.Sprintf("Comment line %d: Indentation error: expected indentation "+
				"to remain at %d, found %d near \"%s\"\n", lineNo, currentDepth, newDepth, line))

		} else {
			// Append to current definition (without indentation)
			currentItem.desc += depthRE.ReplaceAllString(line, "$2") + "\n"
		}
	}
}
1067183
func (s *VMGroupService) GetInstanceGroupByName(name string, opts ...OptionFunc) (*InstanceGroup, int, error) {
	id, count, err := s.GetInstanceGroupID(name, opts...)
	if err != nil {
		return nil, count, err
	}

	r, count, err := s.GetInstanceGroupByID(id, opts...)
	if err != nil {
		return nil, count, err
	}
	return r, count, nil
}
1273529
func t(tags []string) string {
	for i, v := range tags {
		tags[i] = strings.Replace(v, ":", "=", 1)
	}
	t := ""
	if len(tags) > 0 {
		t = "" + strings.Join(tags, ",")
	}
	return t
}
516667
func main() {

	var inputbytes, utf8bytes, outputbytes []byte

	flag.Parse()

	// print help/version/list/usage...
	someSortOfHelp()

	// read input from stdin or file
	inputbytes = getInputBytes()

	// convert inputformat to UTF-8 (decode)
	utf8bytes = getUtf8FromInput(inputbytes)

	// convert UTF-8 to output format (encode)
	outputbytes = convertToDesired(utf8bytes)

	// write output to stdout or file
	writeOutput(outputbytes)

}
1071986
func (row *Row) Init() {
	// Initial values
	row.insertColumnLength = len(row.PK) + len(row.Fields)
	row.updateColumnLength = len(row.PK) + len(row.Fields)
	row.pkColumns = make([]string, 0)
	row.pkValues = make([]interface{}, 0)
	row.insertColumns = make([]string, 0)
	row.updateColumns = make([]string, 0)
	row.insertValues = make([]interface{}, 0)
	row.updateValues = make([]interface{}, 0)

	// Get and sort map keys
	var i int
	pkKeys := make([]string, len(row.PK))
	i = 0
	for pkKey := range row.PK {
		pkKeys[i] = pkKey
		i++
	}
	sort.Strings(pkKeys)
	fieldKeys := make([]string, len(row.Fields))
	i = 0
	for fieldKey := range row.Fields {
		fieldKeys[i] = fieldKey
		i++
	}
	sort.Strings(fieldKeys)

	// Primary keys
	for _, pkKey := range pkKeys {
		row.pkColumns = append(row.pkColumns, pkKey)
		row.pkValues = append(row.pkValues, row.PK[pkKey])
		row.insertColumns = append(row.insertColumns, pkKey)
		row.updateColumns = append(row.updateColumns, pkKey)
		row.insertValues = append(row.insertValues, row.PK[pkKey])
		row.updateValues = append(row.updateValues, row.PK[pkKey])
	}

	// Rest of the fields
	for _, fieldKey := range fieldKeys {
		sv, ok := row.Fields[fieldKey].(string)
		if ok && sv == onInsertNow {
			row.insertColumns = append(row.insertColumns, fieldKey)
			row.insertValues = append(row.insertValues, time.Now())
			row.updateColumnLength--
			continue
		}
		if ok && sv == onUpdateNow {
			row.updateColumns = append(row.updateColumns, fieldKey)
			row.updateValues = append(row.updateValues, time.Now())
			row.insertColumnLength--
			continue
		}
		row.insertColumns = append(row.insertColumns, fieldKey)
		row.updateColumns = append(row.updateColumns, fieldKey)
		row.insertValues = append(row.insertValues, row.Fields[fieldKey])
		row.updateValues = append(row.updateValues, row.Fields[fieldKey])
	}
}
288611
func main() {
	opts := CliOptions{}
	_, err := flags.Parse(&opts)
	if err != nil {
		log.Fatal(err)
	}
	err = config.LoadDotEnvFirst(opts.EnvFile, os.Getenv("ENV_PATH"), "./.env")
	if err != nil {
		log.Fatal(err)
	}
	rcCfg, err := NewRingCentralConfigEnv()
	if err != nil {
		log.Fatal(err)
	}

	apiClient, err := ru.NewApiClientPassword(
		rcCfg.ApplicationCredentials(),
		rcCfg.PasswordCredentials())
	if err != nil {
		log.Fatal(err)
	}

	params := rc.CreateSmsMessage{
		From: rc.MessageStoreCallerInfoRequest{
			PhoneNumber: os.Getenv("RINGCENTRAL_DEMO_SMS_FROM")},
		To: []rc.MessageStoreCallerInfoRequest{
			{
				PhoneNumber: os.Getenv("RINGCENTRAL_DEMO_SMS_TO")}},
		Text: os.Getenv("RINGCENTRAL_DEMO_SMS_TEXT")}

	fmtutil.PrintJSON(params)

	info, resp, err := apiClient.MessagesApi.SendSMS(context.Background(), "~", "~", params)

	if err != nil {
		panic(err)
	} else if resp.StatusCode > 299 {
		panic(fmt.Errorf("API Status %v", resp.StatusCode))
	}
	fmtutil.PrintJSON(info)

	fmt.Println("DONE")
}