// StringCast like Cast, but parses a string. Will also panic if it fails to parse.
341838
func StringCast(s string) Multiaddr {
	m, err := NewMultiaddr(s)
	if err != nil {
		panic(fmt.Errorf("multiaddr failed to parse: %s", err))
	}
	return m
}
842787
func String(input interface{}) (output string, err error) {

	switch castValue := input.(type) {
	case Stringer:
		output = castValue.String()
		return
	case string:
		output = string(castValue)
		return
	case []byte:
		output = string(castValue)
		return
	case int:
		output = strconv.Itoa(castValue)
		return
	case int8:
		output = strconv.Itoa(int(castValue))
		return
	case int16:
		output = strconv.Itoa(int(castValue))
		return
	case int32:
		output = strconv.Itoa(int(castValue))
		return
	case int64:
		output = strconv.FormatInt(castValue, 10)
		return
	case uint:
		output = strconv.FormatUint(uint64(castValue), 10)
		return
	case uint8:
		output = strconv.FormatUint(uint64(castValue), 10)
		return
	case uint16:
		output = strconv.FormatUint(uint64(castValue), 10)
		return
	case uint32:
		output = strconv.FormatUint(uint64(castValue), 10)
		return
	case uint64:
		output = strconv.FormatUint(uint64(castValue), 10)
		return
	case float32:
		// What exact value for perc value
		output = strconv.FormatFloat(float64(castValue), 'g', -1, 64)
		return
	case float64:
		// What exact value for perc value
		output = strconv.FormatFloat(castValue, 'g', -1, 64)
		return
	case nil:
		output = ""
		return
	case bool:
		output = strconv.FormatBool(castValue)
		return
	default:
		err = NewCastError("Could not convert to string")
	}
	return
}
669755
func (s *StructInjector) String() (trace string) {
	for i, f := range s.fields {
		elemField := s.elemType.FieldByIndex(f.FieldIndex)
		trace += fmt.Sprintf("[%d] %s binding: '%s' for field '%s %s'\n",
			i+1, bindTypeString(f.Object.BindType), f.Object.Type.String(),
			elemField.Name, elemField.Type.String())
	}

	return
}
1057441
func CastToString(value interface{}) string {
	casted, ok := value.(string)

	if !ok {
		castedStr := fmt.Sprintf("%v", value)
		casted = castedStr
	}

	return casted
}
398056
func (sc ScriptClass) String() string {
	name, found := scriptClassToName[sc]
	if !found {
		return ScriptClassInvalid.String() // better be in scriptClassToName!
	}
	return name
}
937211
func (e *Encoder) stringify(v reflect.Value, child bool) (string, bool) {
	if !isSupportedKind(v.Kind()) {
		return "", false
	}
	switch v.Kind() {
	case reflect.Bool:
		return strconv.FormatBool(v.Bool()), true
	case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
		return strconv.Itoa(int(v.Int())), true
	case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64:
		return strconv.FormatUint(uint64(v.Uint()), e.base), true
	case reflect.Float32:
		return strconv.FormatFloat(v.Float(), 'E', -1, 32), true
	case reflect.Float64:
		return strconv.FormatFloat(v.Float(), 'E', -1, 64), true
	case reflect.Complex64, reflect.Complex128:
		return fmt.Sprintf("%g", v.Complex()), true
	case reflect.String:
		return v.String(), true
	case reflect.Ptr:
		return e.stringify(v.Elem(), child)
	default:
		cols, ok := e.marshal(v, true)
		if !ok {
			return "", false
		}
		r := cols[0]
		for i := 1; i < len(cols); i++ {
			r = fmt.Sprintf("%s,%s", r, cols[i])
		}
		if strings.HasPrefix(r, "(") {
			return r, true
		}
		return fmt.Sprintf("%s%s%s", e.sepBeg, r, e.sepEnd), true
	}
}
1364275
func Stringify(message interface{}) string {
	var buf bytes.Buffer
	v := reflect.ValueOf(message)
	stringifyValue(&buf, v)
	return buf.String()
}
394828
func StringOrBytes(value interface{}) (isString bool, str string, isBytes bool, bs []byte) {
	v := reflect.ValueOf(value)
	if v.Kind() == reflect.String {
		str = v.String()
		isString = true
	} else if v.Kind() == reflect.Slice && v.Type() == bytesType {
		bs = v.Interface().([]byte)
		isBytes = true
	}
	return
}
72978
func (v *Type) String() string {
	if v == nil {
		return "<nil>"
	}

	var fields [6]string
	i := 0
	if v.SimpleType != nil {
		fields[i] = fmt.Sprintf("SimpleType: %v", *(v.SimpleType))
		i++
	}
	if v.SliceType != nil {
		fields[i] = fmt.Sprintf("SliceType: %v", v.SliceType)
		i++
	}
	if v.KeyValueSliceType != nil {
		fields[i] = fmt.Sprintf("KeyValueSliceType: %v", v.KeyValueSliceType)
		i++
	}
	if v.MapType != nil {
		fields[i] = fmt.Sprintf("MapType: %v", v.MapType)
		i++
	}
	if v.ReferenceType != nil {
		fields[i] = fmt.Sprintf("ReferenceType: %v", v.ReferenceType)
		i++
	}
	if v.PointerType != nil {
		fields[i] = fmt.Sprintf("PointerType: %v", v.PointerType)
		i++
	}

	return fmt.Sprintf("Type{%v}", strings.Join(fields[:i], ", "))
}
1262837
func (schema *Schema) stringValue(v interface{}) *string {
	switch v := v.(type) {
	default:
		fmt.Printf("stringValue: unexpected type %T\n", v)
	case string:
		return &v
	}
	return nil
}
1264074
func (a VarRefs) Strings() []string {
	s := make([]string, len(a))
	for i, ref := range a {
		s[i] = ref.Val
	}
	return s
}
219333
func (v *KeyValue_GetValue_Args) String() string {
	if v == nil {
		return "<nil>"
	}

	var fields [1]string
	i := 0
	if v.Key != nil {
		fields[i] = fmt.Sprintf("Key: %v", *(v.Key))
		i++
	}

	return fmt.Sprintf("KeyValue_GetValue_Args{%v}", strings.Join(fields[:i], ", "))
}
244236
func StringList(v ...Stringable) *StringListExpr {
	rv := &StringListExpr{Literal: []*StringExpr{}}
	for _, item := range v {
		rv.Literal = append(rv.Literal, item.String())
	}
	return rv
}
884059
func (rp *Reply) StringValue() (string, error) {
	if rp.Type == ErrorReply {
		return "", errors.New(rp.Error)
	}
	if rp.Type != BulkReply {
		return "", errors.New("invalid reply type, not bulk")
	}
	if rp.Bulk == nil {
		return "", nil
	}
	return string(rp.Bulk), nil
}
514727
func NewStringTypeDef(init ...*StringTypeDef) *StringTypeDef {
	var o *StringTypeDef
	if len(init) == 1 {
		o = init[0]
	} else {
		o = new(StringTypeDef)
	}
	return o
}
1212248
func ToStringMapIntE(i interface{}) (map[string]int, error) {
	var m = map[string]int{}
	if i == nil {
		return m, fmt.Errorf("unable to cast %#v of type %T to map[string]int", i, i)
	}

	switch v := i.(type) {
	case map[interface{}]interface{}:
		for k, val := range v {
			m[ToString(k)] = ToInt(val)
		}
		return m, nil
	case map[string]interface{}:
		for k, val := range v {
			m[k] = ToInt(val)
		}
		return m, nil
	case map[string]int:
		return v, nil
	case string:
		err := jsonStringToObject(v, &m)
		return m, err
	}

	if reflect.TypeOf(i).Kind() != reflect.Map {
		return m, fmt.Errorf("unable to cast %#v of type %T to map[string]int", i, i)
	}

	mVal := reflect.ValueOf(m)
	v := reflect.ValueOf(i)
	for _, keyVal := range v.MapKeys() {
		val, err := ToIntE(v.MapIndex(keyVal).Interface())
		if err != nil {
			return m, fmt.Errorf("unable to cast %#v of type %T to map[string]int", i, i)
		}
		mVal.SetMapIndex(keyVal, reflect.ValueOf(val))
	}
	return m, nil
}
522781
func ToString(v Value) string {
	if s, ok := v.(String); ok {
		return string(s)
	}
	return StringOf(v)
}