How to concatenate string with integer in Go

1 Answer

0 votes
package main

import (
	"fmt"
	"strconv"
)

func main() {
	num := 42
	str := "The answer is: "
	
	result := str + strconv.Itoa(num)
	
	fmt.Println(result)
}



/*
run:

The answer is: 42

*/

 



answered Jun 17, 2025 by avibootz

Related questions

2 answers 392 views
392 views asked Aug 18, 2020 by avibootz
1 answer 252 views
252 views asked Aug 11, 2020 by avibootz
2 answers 293 views
293 views asked May 27, 2020 by avibootz
1 answer 187 views
2 answers 339 views
...