Hex is just hexadecimal representation of RGB values you can simply do something like

Go:
1
2
3
4
5
6
7
8
9
10
11
12
package main

import (
	"fmt"
	"strconv"
)

func main() {
	R, G, B := 240, 128, 45
	fmt.Printf("#%02x%02x%02x\n", R, G, B)
	fmt.Printf("#%s%s%s\n", strconv.FormatInt(int64(R), 16), strconv.FormatInt(int64(G), 16), strconv.FormatInt(int64(B), 16))
}

Output:

plaintext:
1
2
#f0802d
#f0802d

Go:
1
2
3
4
5
// HexColor converts hex color to color.RGBA with "#FFFFFF" format
func HexColor(hex string) color.RGBA {
	values, _ := strconv.ParseUint(string(hex[1:]), 16, 32)
	return color.RGBA{R: uint8(values >> 16), G: uint8((values >> 8) & 0xFF), B: uint8(values & 0xFF), A: 255}
}