Golang : concatenate(combine) strings
Once in a blue moon, a programmer will bound to process input strings and manipulate the strings into something meaningful ... just like combining DNA. In this tutorial, we will learn how to combine or concatenate(link) couple of strings together.
The code below used the fmt.Sprint() function to combine the three separated strings.
package main
import "fmt"
func main() {
chinese := "你好"
english := "Hello"
malay := "apa khabar"
concatenated := fmt.Sprint(chinese +" "+ english +" "+ malay)
fmt.Println(concatenated)
}
Output :
你好 Hello apa khabar
Is there any other ways to combine strings in Go ? I'm sure there is. Just that I've not figure it all out yet by the time of writing this tutorial. Share it in comment below if you have better ways to combine strings in Golang.
By Adam Ng
IF you gain some knowledge or the information here solved your programming problem. Please consider donating to the less fortunate or some charities that you like. Apart from donation, planting trees, volunteering or reducing your carbon footprint will be great too.
Advertisement
Tutorials
+6.3k Android Studio : How to detect camera, activate and capture example
+9.3k Golang : Generate 403 Forbidden to protect a page or prevent indexing by search engine
+12.7k Golang : convert rune to unicode hexadecimal value and back to rune character
+7.3k Swift : Convert (cast) Character to Integer?
+6.3k Golang : Dealing with struct's private part
+10.6k CodeIgniter : Import Linkedin data
+7.2k How to show different content from website server when AdBlock is detected?
+10.4k Golang : Surveillance with web camera and OpenCV
+9.2k Golang : Convert file unix timestamp to UTC time example
+15.8k Golang : Get number of CPU cores
+5.5k Golang : Calculate diameter, circumference, area, sphere surface and volume
+25.7k Golang : Find files by name - cross platform example