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
+26.4k Golang : Move file to another directory
+5.7k Unix/Linux : How to fix CentOS yum duplicate glibc or device-mapper-libs dependency error?
+10.8k Golang : Determine if time variables have same calendar day
+9.8k Golang : Sieve of Eratosthenes algorithm
+4.3k Responsive Google Adsense
+10.3k Golang : Display a text file line by line with line number example
+4.4k Javascript : How to loop over and parse JSON data?
+2k Golang : Fix go-cron set time not working issue
+4.3k Golang : Qt update UI elements with core.QCoreApplication_ProcessEvents
+7.8k Golang : Find duplicate files with filepath.Walk
+20.9k Golang : Read directory content with filepath.Walk()
+5.8k Default cipher that OpenSSL used to encrypt a PEM file