Course Content
Introduction to GoLang
Introduction to GoLang
Strings
In Go, strings are sequences of Unicode characters, which essentially means they represent textual data. String data is always enclosed in double quotation marks ("
) or backticks. The string data type is represented by the string
keyword.
index.go
Note
A string is a data type in Go, while a string literal refers to the actual representation of a string value within the source code, for example,
Hello World
.
We can write a string literal in multiple lines by enclosing it in backticks (``). You can see the difference in the following program:
index.go
Strings can be joined together using the plus (+
) operator:
index.go
The process of joining two strings using the (+
) operator is called string concatenation.
Which of the following is the correct way to declare a string variable in Go?
Select a few correct answers
Everything was clear?