Hexadecimal conversion of golang language

func main(){
    n := "0fa8" 
    // 4008
}

the question is this: there is a hexadecimal string type of "0fa8", converted to decimal to 4008, how to convert a hexadecimal string into plastic shaping?
tried fmt.Sprintf and strconv but failed.

Go
May.31,2022

num, _: = strconv.ParseInt ("0fa8", 16,0)


also has a method you found yourself, using strconv.ParseInt .


<ol> <li> 16 , hex.DecodeString() </li> <li>, binary.BigEndian.Uint16() </li> </ol>

package main

import (
    "encoding/binary"
    "encoding/hex"
    "fmt"
)

func main() {
    bs, _ := hex.DecodeString("0fa8")
    num := binary.BigEndian.Uint16(bs[:2])
    fmt.Println(num)
}
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e4d42a-27457.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e4d42a-27457.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?