How to append string in golang?

Hi Friends 👋,

Welcome To aGuideHub! ❤️

Today, we will learn to concatenate strings in golang, here we use the + operator to concate strings like javascript “LOVE ICON”…

In the following example, we are creating three variables and using the + operator to append one after one and after that storing in a new str variable.

Here, we are also using ” ” ( space ) as a separator.

package main
  
import "fmt"
  
func main() {
  
    // Creating and initializing strings
    str1 := "Welcome"
    str2 := "To"
    str3 := "aGuideHub"
  
    str := str1 + " " + str2 + " " + str3;
    fmt.Println("String: ", str)
  
}

In the above code, we have just created three variables, use the + operator concate, and output in front of you.

Output

Golang, append, string, example

Try it yourself

All the best 👍

Premium Content

You can get all the below premium content directly in your mail when you subscribe us

Books

Portfolio Template

View | Get Source Code

Cheat Sheets

Cheat Sheets Books are basically Important useful notes which we use in our day-to-day life.

I'm working on some more Cheat Sheets book on Jquery, TypeScript, React js and for other languages. I will send it once it's completed.

Stay tuned working on React Js Cheat Sheets Book

Related Posts