Example of converting hexadecimal to integer in Go

This is an example Go program for hexadecimal-to-integer.

package main

import (

func main() {
        hex := "beef"
        value, err := strconv.ParseInt(hex, 16, 64)
        if err != nil {
                fmt.Printf ("Conversion failed: %s\n", err)
        } else {
                fmt.Printf ("Hexadecimal '%s' is integer %d (%X)",
                        hex, value, value)


The output of the example looks like this:

Hexadecimal beef is integer 48879 (BEEF)

Copyright © Ben Bullock 2009-2024. All rights reserved. For comments, questions, and corrections, please email Ben Bullock (benkasminbullock@gmail.com) or use the discussion group at Google Groups. / Privacy / Disclaimer