Welcome to collectivesolver - Programming & Software Q&A with code examples. A website with trusted programming answers. All programs are tested and work.

Contact: aviboots(AT)netvision.net.il

Buy a domain name - Register cheap domain names from $0.99 - Namecheap

Scalable Hosting That Grows With You

Secure & Reliable Web Hosting, Free Domain, Free SSL, 1-Click WordPress Install, Expert 24/7 Support

Semrush - keyword research tool

Boost your online presence with premium web hosting and servers

Disclosure: My content contains affiliate links.

39,970 questions

51,912 answers

573 users

How to convert int to hexadecimal string in Go

3 Answers

0 votes
package main
 
import (
    "fmt"
    "strconv"
)
 
func main() {
    i := 255
    s := strconv.FormatInt(int64(i) , 16)

    fmt.Printf("Type : %T \nValue : %v\n", s, s) 
}
 
 
 
 
/*
run:
 
Type : string 
Value : ff
 
*/

 



answered May 26, 2020 by avibootz
0 votes
package main
 
import (
    "fmt"
)
 
func main() {
    i := 255

    s := fmt.Sprintf("%x", i)

    fmt.Printf("Type : %T \nValue : %v\n", s, s) 
}
 
 
 
 
/*
run:
 
Type : string 
Value : ff
 
*/

 



answered May 26, 2020 by avibootz
0 votes
package main
 
import (
    "fmt"
)
 
func main() {
    i := 65535

    s := fmt.Sprintf("%X", i)

    fmt.Printf("Type : %T \nValue : %v\n", s, s) 
}
 
 
 
 
/*
run:
 
Type : string 
Value : FFFF
 
*/

 



answered May 26, 2020 by avibootz

Related questions

1 answer 208 views
1 answer 170 views
1 answer 77 views
1 answer 59 views
1 answer 126 views
1 answer 225 views
1 answer 251 views
...