func (permission *Permission) Concat(newPermission *Permission) *Permission {
	var result = Permission{
		Role:         Global,
		AllowedRoles: map[PermissionMode][]string{},
		DeniedRoles:  map[PermissionMode][]string{},
	}

	var appendRoles = func(p *Permission) {
		if p != nil {
			result.Role = p.Role

			for mode, roles := range p.DeniedRoles {
				result.DeniedRoles[mode] = append(result.DeniedRoles[mode], roles...)
			}

			for mode, roles := range p.AllowedRoles {
				result.AllowedRoles[mode] = append(result.AllowedRoles[mode], roles...)
			}
		}
	}

	appendRoles(newPermission)
	appendRoles(permission)
	return &result
}
func (permission *Permission) Concat(newPermission *Permission) *Permission {
	var result = Permission{
		Role:         Global,
		AllowedRoles: map[PermissionMode][]string{},
		DeniedRoles:  map[PermissionMode][]string{},
	}

	var appendRoles = func(p *Permission) {
		if p != nil {
			result.Role = p.Role

			for mode, roles := range p.DeniedRoles {
				result.DeniedRoles[mode] = append(result.DeniedRoles[mode], roles...)
			}

			for mode, roles := range p.AllowedRoles {
				result.AllowedRoles[mode] = append(result.AllowedRoles[mode], roles...)
			}
		}
	}

	appendRoles(newPermission)
	appendRoles(permission)
	return &result
}
func ( permission * Permission ) Concat ( newPermission * Permission ) * Permission { var result = Permission { Role : Global , AllowedRoles : map [ PermissionMode ] [ ] string { } , DeniedRoles : map [ PermissionMode ] [ ] string { } , } var appendRoles = func ( p * Permission ) { if p != nil { result . Role = p . Role for mode , roles := range p . DeniedRoles { result . DeniedRoles [ mode ] = append ( result . DeniedRoles [ mode ] , roles ... ) } for mode , roles := range p . AllowedRoles { result . AllowedRoles [ mode ] = append ( result . AllowedRoles [ mode ] , roles ... ) } } } appendRoles ( newPermission ) appendRoles ( permission ) return & result }
// Concat concat two permissions into a new one
Concat concat two permissions into a new one