bin-templater/merger/merger.go
func transform(in interface{}) (_ interface{}, err error) {
	switch in.(type) {
	case map[interface{}]interface{}:
		o := make(map[string]interface{})
		for k, v := range in.(map[interface{}]interface{}) {
			sk := ""
			switch k.(type) {
			case string:
				sk = k.(string)
			case int:
				sk = strconv.Itoa(k.(int))
			default:
				return nil, errors.New(
					fmt.Sprintf("type not match: expect map key string or int get: %T", k))
			}
			v, err = transform(v)
			if err != nil {
				return nil, err
			}
			o[sk] = v
		}
		return o, nil
	case []interface{}:
		in1 := in.([]interface{})
		len1 := len(in1)
		o := make([]interface{}, len1)
		for i := 0; i < len1; i++ {
			o[i], err = transform(in1[i])
			if err != nil {
				return nil, err
			}
		}
		return o, nil
	default:
		return in, nil
	}
}
func transform(in interface{}) (_ interface{}, err error) {
	switch in.(type) {
	case map[interface{}]interface{}:
		o := make(map[string]interface{})
		for k, v := range in.(map[interface{}]interface{}) {
			sk := ""
			switch k.(type) {
			case string:
				sk = k.(string)
			case int:
				sk = strconv.Itoa(k.(int))
			default:
				return nil, errors.New(
					fmt.Sprintf("type not match: expect map key string or int get: %T", k))
			}
			v, err = transform(v)
			if err != nil {
				return nil, err
			}
			o[sk] = v
		}
		return o, nil
	case []interface{}:
		in1 := in.([]interface{})
		len1 := len(in1)
		o := make([]interface{}, len1)
		for i := 0; i < len1; i++ {
			o[i], err = transform(in1[i])
			if err != nil {
				return nil, err
			}
		}
		return o, nil
	default:
		return in, nil
	}
}
func transform ( in interface { } ) ( _ interface { } , err error ) { switch in . ( type ) { case map [ interface { } ] interface { } : o := make ( map [ string ] interface { } ) for k , v := range in . ( map [ interface { } ] interface { } ) { sk := " " switch k . ( type ) { case string : sk = k . ( string ) case int : sk = strconv . Itoa ( k . ( int ) ) default : return nil , errors . New ( fmt . Sprintf ( " " , k ) ) } v , err = transform ( v ) if err != nil { return nil , err } o [ sk ] = v } return o , nil case [ ] interface { } : in1 := in . ( [ ] interface { } ) len1 := len ( in1 ) o := make ( [ ] interface { } , len1 ) for i := 0 ; i < len1 ; i ++ { o [ i ] , err = transform ( in1 [ i ] ) if err != nil { return nil , err } } return o , nil default : return in , nil } }
// transform YAML to JSON
transform YAML to JSON