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
+5.5k Golang : Display advertisement images or strings on random order
+11.5k CodeIgniter : Import Linkedin data
+5.2k Golang : Convert lines of string into list for delete and insert operation
+8.8k Golang : Get final balance from bit coin address example
+20k Golang : Convert(cast) bytes.Buffer or bytes.NewBuffer type to io.Reader
+11.2k CodeIgniter : How to check if a session exist in PHP?
+6.4k Golang : Selection sort example
+9.3k Golang : Create and shuffle deck of cards example
+10k Golang : Channels and buffered channels examples
+7.4k Golang : Fixing Gorilla mux http.FileServer() 404 problem
+10.6k Golang : Create matrix with Gonum Matrix package example
+4.7k Chrome : How to block socketloop.com links in Google SERP?