You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: index.go
    path of file: ./repos/erda/internal/tools/monitor/core/storekit/elasticsearch/index
    
    the code of the file until where you have to start completion: // Copyright (c) 2021 Terminus, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//      http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distri
    
func FindElection(ctx servicehub.Context, required bool) (election.Interface, error) {
	const service = "etcd-election"
	var obj interface{}
	var name string
	if len(ctx.Label()) > 0 {
		name = service + "@" + ctx.Label()
		obj = ctx.Service(name)
	}
	if obj == nil {
		name = service + "@index"
		obj = ctx.Service(name)
	}
	if obj == nil {
		name = service
		obj = ctx.Service(name)
	}
	if obj != nil {
		election, ok := obj.(election.Interface)
		if !ok {
			return nil, fmt.Errorf("%q is not election.Interface", name)
		}
		ctx.Logger().Debugf("use Election(%q) for index clean", name)
		return election, nil
	} else if required {
		return nil, fmt.Errorf("%q is required", service)
	}
	return nil, nil
}