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.
- fmt.print() Function in Golang With Examples
- How to Print Specific date-time in Golang?
- How to print struct variables data in Golang?
- HTML | DOM Style quotes Property
- How to Create and Print Multi Dimensional Slice in Golang?
- How to Get the String in Specified Base in Golang?
- string package in Golang
- How to Trim a String in Golang?
- How to Reverse a String in Golang?
- How to Split a String in Golang?
- How to find the last index value of specified string in Golang?
- How to convert a string in uppercase in Golang?
- How to find the index value of specified string in Golang?
- Golang Program that uses String Switch
- How to check the specified rune in Golang String?
- How to write backslash in Golang string?
- Golang | Splitting the string after the specified separator
- string.Contains Function in Golang with Examples
- How to Replace Characters 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 firstname.lastname@example.org. 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.