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: image_selector.go
    path of file: ./repos/devspace/pkg/devspace/imageselector
    
    the code of the file until where you have to start completion: package imageselector

import (
	"fmt"
	"regexp"
	"strings"

	"github.com/loft-sh/devspace/pkg/devspace/config"
	"github.com/loft-sh/devspace/pkg/devspace/dependency/types"
	"github.com/loft-sh/devspace/pkg/util/dockerfile"
)

type ImageSelector struct {
	// Image is the resolved docker image inclusive tag
	Image string
	// Dependency is the dependency this image selector was loaded from
	Dependency types.Dependency
}

func Resolve(configImageName string, config config.Config, dependencies []types.Dependency) (*ImageSelector, error) {
	if configImageName != "" && config != nil && config.LocalCache() != nil && config.Config() != nil {
		var (
			c         = config.Config()
			generated = config.LocalCache()
		)

		// check if cached
		imageCache, _ := generated.GetImageCache(configImageName)
		if imageCache.ImageName != "" && imageCache.Tag != "" && c.Images != nil && c.Images[configImageName] != nil {
			return &ImageSelector{
				Image: imageCache.ResolveImage() + ":" + imageCac
    
func CompareImageNames(selector string, image2 string) bool {
	image1 := selector

	// we replace possible # with a's here to avoid an parsing error
	// since the tag is stripped anyways it doesn't really matter if we lose
	// information where the # were
	tagStrippedImage1, _, err := dockerfile.GetStrippedDockerImageName(strings.ReplaceAll(image1, "#", "a"))
	if err != nil {
		tagStrippedImage1 = image1
	}
	tagStrippedImage2, _, err := dockerfile.GetStrippedDockerImageName(image2)
	if err != nil {
		tagStrippedImage2 = image2
	}

	if tagStrippedImage1 != image1 {
		// In the case that the tag is latest and we find an image that has no tag
		if tagStrippedImage1+":latest" == image1 && tagStrippedImage2 == image2 {
			return true
		}

		// if the tag consists of a # we build a regex
		if strings.Contains(image1, "#") {
			regex := "^" + strings.ReplaceAll(image1, "#", "[a-zA-Z]") + "$"
			exp, err := regexp.Compile(regex)
			if err == nil {
				return exp.MatchString(image2)
			}
		}

		return image1 == image2
	}

	return tagStrippedImage1 == tagStrippedImage2
}