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: jassoncu.go
    path of file: ./repos/retos-programacion-2023/Retos/Reto #37 - COLORES HEX Y RGB [Media]/go
    
    the code of the file until where you have to start completion: package main

import (
	"fmt"
	"image/color"
	"regexp"
	"strconv"
)

func hexToRGB(hex string) (int, int, int, error) {
	// Verificar el formato del color HEX
	hexPattern := regexp.MustCompile(`^#?([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$`)
	if !hexPattern.MatchString(hex) {
		return 0, 0, 0, fmt.Errorf("Formato de color HEX no válido")
	}

	// Quitar el carácter '#' si está presente
	if hex[0] == '#' {
		hex = hex[1:]
	}

	// Convertir a valores RGB
	var r, g, b int
	var err error
	if len(hex) == 3 {
		// Manejar formato corto de 3 caracteres
		r, err = strconv.Atoi(hex[0:1] + hex[0:1])
		if err != nil {
			return 0, 0, 0, err
		}
		g, err = strconv.Atoi(hex[1:2] + hex[1:2])
		if err != nil {
			
    
func hexToRGB(hex string) (int, int, int, error) {
	// Verificar el formato del color HEX
	hexPattern := regexp.MustCompile(`^#?([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$`)
	if !hexPattern.MatchString(hex) {
		return 0, 0, 0, fmt.Errorf("Formato de color HEX no válido")
	}

	// Quitar el carácter '#' si está presente
	if hex[0] == '#' {
		hex = hex[1:]
	}

	// Convertir a valores RGB
	var r, g, b int
	var err error
	if len(hex) == 3 {
		// Manejar formato corto de 3 caracteres
		r, err = strconv.Atoi(hex[0:1] + hex[0:1])
		if err != nil {
			return 0, 0, 0, err
		}
		g, err = strconv.Atoi(hex[1:2] + hex[1:2])
		if err != nil {
			return 0, 0, 0, err
		}
		b, err = strconv.Atoi(hex[2:3] + hex[2:3])
		if err != nil {
			return 0, 0, 0, err
		}
	} else {
		// Manejar formato largo de 6 caracteres
		r, err = strconv.Atoi(hex[0:2])
		if err != nil {
			return 0, 0, 0, err
		}
		g, err = strconv.Atoi(hex[2:4])
		if err != nil {
			return 0, 0, 0, err
		}
		b, err = strconv.Atoi(hex[4:6])
		if err != nil {
			return 0, 0, 0, err
		}
	}

	return r, g, b, nil
}