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
+5k Linux/MacOSX : Search for files by filename and extension with find command
+7.7k Golang : Get final balance from bit coin address example
+25.6k Golang : Find files by name - cross platform example
+3.7k Facebook : How to place save to Facebook button on your website
+12.2k Golang : Verify token from Google Authenticator App
+8k Golang : Play .WAV file from command line
+10.7k Golang : Save webcamera frames to video file
+46.9k Golang : Upload file from web browser to server
+7.8k Golang : Handle sub domain with Gin
+25.4k Golang : How to check if a connection to database is still alive ?
+10.7k Golang : Convert a rune to unicode style string \u
+9.8k Golang : Delay or limit HTTP requests example