Whenever the user wants to double-quote a string, he can’t simply write the string within double quotes inside the fmt.Printf() command. This prints only the text written inside those quotes. To print the string along with quotes, he can use various methods including certain escape characters. There are different ways in Golang to print a string with double-quotes.
1) Quoting a string using %q:
"Welcome to GeeksforGeeks."
Explanation: In the above example, we used “%q” to display our string with double-quotes.
2) Quoting a string using an escape character “\”:
"GeeksforGeeks is a computer science portal"
Explanation: In the above example, we used an escape character “\” to print a string with double-quotes. We can simply do so by adding a backslash(\) before the double-quotes.
3) Double quoting a string using a raw string lateral (`):
Explanation: In the above example, we used a raw string lateral (`) to print a string with double-quotes.
- HTML | DOM Style quotes Property
- How to Create and Print Multi Dimensional Slice in Golang?
- fmt.print() Function in Golang With Examples
- How to Print Specific date-time in Golang?
- How to print struct variables data in Golang?
- How do the PHP equality (== double equals) and identity (=== triple equals) comparison operators differ?
- Double not (!!) operator in PHP
- What does $$ (dollar dollar or double dollar) means in PHP ?
- Go Pointer to Pointer (Double Pointer)
- What is the use of a double-click event in AngularJs?
- What is the difference between single-quoted and double-quoted strings in PHP?
- string.Contains Function in Golang with Examples
- Converting a string variable into Boolean, Integer or Float type in Golang
- Golang Program that uses String Switch
- How to Trim a String in Golang?
- How to convert a string in uppercase in Golang?
- How to convert a string in lower case in Golang?
- Check if the given characters is present in Golang String
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.