Concatenation in Golang

Create new folder named src. In src folder, create new file named main.go as below:

package main

import "fmt"

func main() {

	var firstName string = "John"
	var middleName string = "Thomas"
	var lastName string = "Smith"
	var fullName = firstName + " " + middleName + " " + lastName
	fmt.Println("Full Name: ", fullName)

	var age string = "Age:"
	var value int = 20
	var result string = fmt.Sprintf("%s %d", age, value)
	fmt.Println(result)

}




Open Terminal windows in Visual Studio Code and run command line: go run main.go

Full Name:  John Thomas Smith
Age: 20