func (config *Config) update(node Node) error {
	nodePath := strings.Split(node.Path, "/")
	if len(node.Path) == 0 {
		nodePath = nil
	}
	if len(nodePath) == 0 && node.IsDir {
		return nil
	} else if len(nodePath) == 1 && nodePath[0] == "services" && node.IsDir {
		return config.updateServices(node)
	} else if len(nodePath) >= 2 && nodePath[0] == "services" {
		serviceName := nodePath[1]
		if len(nodePath) == 2 && node.IsDir {
			return config.updateService(node, serviceName)
		} else if len(nodePath) == 3 && nodePath[2] == "frontend" && !node.IsDir {
			var serviceFrontend = ServiceFrontend{
				Meta: Meta{node: node},
			}
			if err := node.unmarshal(&serviceFrontend); err != nil {
				return fmt.Errorf("service %s frontend: %s", serviceName, err)
			}
			return config.updateServiceFrontend(node, serviceName, serviceFrontend)
		} else if len(nodePath) == 3 && nodePath[2] == "backends" && node.IsDir {
			return config.updateServiceBackends(node, serviceName)
		} else if len(nodePath) >= 4 && nodePath[2] == "backends" {
			backendName := nodePath[3]
			if len(nodePath) == 4 && !node.IsDir {
				var serviceBackend = ServiceBackend{
					Meta:   Meta{node: node},
					Weight: ServiceBackendWeight,
				}
				if err := node.unmarshal(&serviceBackend); err != nil {
					return fmt.Errorf("service %s backend %s: %s", serviceName, backendName, err)
				}
				return config.updateServiceBackend(node, serviceName, backendName, serviceBackend)
			} else {
				return fmt.Errorf("Ignore unknown service %s backends node", serviceName)
			}
		} else {
			return fmt.Errorf("Ignore unknown service %s node", serviceName)
		}
	} else if len(nodePath) == 1 && nodePath[0] == "routes" && node.IsDir {
		return config.updateRoutes(node)
	} else if len(nodePath) >= 2 && nodePath[0] == "routes" {
		routeName := nodePath[1]
		if len(nodePath) == 2 && !node.IsDir {
			var route = Route{
				Meta: Meta{node: node},
			}
			if err := node.unmarshal(&route); err != nil {
				return fmt.Errorf("route %s: %s", routeName, err)
			}
			return config.updateRoute(node, routeName, route)
		} else {
			return fmt.Errorf("Ignore unknown route node")
		}
	} else {
		return fmt.Errorf("Ignore unknown node")
	}
}
Update config from Node.

This modifieds the Config in-place, and is not safe against any concurrent usage.
package config
import (
	"fmt"
	"strings"
)
type Meta struct {
	node Node  
}
func (meta Meta) Source() string {
	if meta.node.Source != nil {
		return meta.node.Source.String()
	} else {
		return ""
	}
}
func (meta Meta) Path() string {
	return meta.node.Path
}
type ServiceFrontend struct {
	Meta `json:"-"`
	IPv4 string `json:"ipv4,omitempty"`
	IPv6 string `json:"ipv6,omitempty"`
	TCP  uint16 `json:"tcp,omitempty"`
	UDP  uint16 `json:"udp,omitempty"`
}
type ServiceBackend struct {
	Meta `json:"-"`
	IPv4 string `json:"ipv4,omitempty"`
	IPv6 string `json:"ipv6,omitempty"`
	TCP  uint16 `json:"tcp,omitempty"`
	UDP  uint16 `json:"udp,omitempty"`
	Weight uint `json:"weight"`  
}
const ServiceBackendWeight uint = 10
type Service struct {
	Meta `json:"-"`
	Frontend *ServiceFrontend
	Backends map[string]ServiceBackend
}
func (service *Service) setBackend(backendName string, serviceBackend ServiceBackend) {
	if service.Backends == nil {
		service.Backends = map[string]ServiceBackend{backendName: serviceBackend}
	} else {
		service.Backends[backendName] = serviceBackend
	}
}
func (service *Service) merge(other Service) {
	if other.Frontend != nil {
		service.Frontend = other.Frontend
	}
	if service.Backends == nil {
		service.Backends = make(map[string]ServiceBackend)
	}
	for backendName, backend := range other.Backends {
		service.Backends[backendName] = backend
	}
}
type Route struct {
	Meta `json:"-"`
	Prefix string `json:",omitempty"`
	Gateway string `json:",omitempty"`
	IPVSMethod string `json:",omitempty"`
}
type Config struct {
	Routes   map[string]Route
	Services map[string]Service
}
func (config *Config) setService(serviceName string, service Service) {
	if config.Services == nil {
		config.Services = map[string]Service{serviceName: service}
	} else {
		config.Services[serviceName] = service
	}
}
func (config *Config) updateServices(node Node) error {
	if node.Remove {
		config.Services = nil
	}
	return nil
}
func (config *Config) updateService(node Node, serviceName string) error {
	if node.Remove {
		delete(config.Services, serviceName)
	} else {
		service := config.Services[serviceName]
		config.setService(serviceName, service)
	}
	return nil
}
func (config *Config) updateServiceFrontend(node Node, serviceName string, serviceFrontend ServiceFrontend) error {
	service := config.Services[serviceName]
	if node.Remove {
		service.Frontend = nil
	} else {
		service.Frontend = &serviceFrontend
	}
	config.setService(serviceName, service)
	return nil
}
func (config *Config) updateServiceBackends(node Node, serviceName string) error {
	service := config.Services[serviceName]
	if node.Remove {
		service.Backends = nil
	}
	config.setService(serviceName, service)
	return nil
}
func (config *Config) updateServiceBackend(node Node, serviceName string, backendName string, serviceBackend ServiceBackend) error {
	service := config.Services[serviceName]
	if node.Remove {
		delete(service.Backends, backendName)
	} else {
		service.setBackend(backendName, serviceBackend)
	}
	config.setService(serviceName, service)
	return nil
}
func (config *Config) updateRoutes(node Node) error {
	if node.Remove {
		config.Routes = nil
	}
	return nil
}
func (config *Config) updateRoute(node Node, routeName string, route Route) error {
	if node.Remove {
		delete(config.Routes, routeName)
	} else if config.Routes == nil {
		config.Routes = map[string]Route{routeName: route}
	} else {
		config.Routes[routeName] = route
	}
	return nil
}