// Set sets a property.
Set sets a property.
// Set sets a property .
func (s State) Set(path string, v interface{}) {
	parts := strings.Split(path, ".")
	m := s
	for i := 0; i < len(parts)-1; i++ {
		part := parts[i]
		value, ok := m[part]
		if !ok || !isMap(value) {
			p := make(map[string]interface{})
			m[part] = p
			m = p
			continue
		}
		m = m[part].(map[string]interface{})
	}
	if p, ok := v.(State); ok {
		v = map[string]interface{}(p)
	}
	key := parts[len(parts)-1]
	m[key] = v
}
func ( s State ) Set ( path string , v interface { } ) { parts := strings . Split ( path , " " ) m := s for i := 0 ; i < len ( parts ) - 1 ; i ++ { part := parts [ i ] value , ok := m [ part ] if ! ok || ! isMap ( value ) { p := make ( map [ string ] interface { } ) m [ part ] = p m = p continue } m = m [ part ] . ( map [ string ] interface { } ) } if p , ok := v . ( State ) ; ok { v = map [ string ] interface { } ( p ) } key := parts [ len ( parts ) - 1 ] m [ key ] = v }
Set sets a property.
Set sets a property .
// If the part key doesn't exist yet or is primitive type, create it. // Continue through the chain of maps // Internal types are only primitive types and maps, not State. Convert State // to map[string]interface{}.