In most of the programming languages, Backslash (\) works as an escape sequence character and the same is the case with Golang. Thus, if a user needs to write backslash in a string, he can make use of the two common methods.
1. A user can use another backslash just before the backslash (\) he/she wants to display.
\Hello, Welcome to GeeksforGeeks
Explanation: Suppose, the user wants to write backslash at the starting of the string. This is done by using an escape operator “\” just before the desired backslash as shown in the above example. In this manner, the user can insert the backslash at any desired position in the string.
2. Another approach is to use a raw string literal (`).
Explanation: In this example, we used a raw string lateral (`) to write a backslash in the string. If a user wants to write a string in between the backslashes, he can do so by writing the desired string within raw string literals (`) as shown in this example.
- How to Read and Write the Files in Golang?
- 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
- Repeating a String for Specific Number of Times in Golang
- How to Split a String in Golang?
- How to find the index value of specified string in Golang?
- How to find the last index value of specified string in Golang?
- How to Count the Number of Repeated Characters in a Golang String?
- Check if the String starts with specified prefix in Golang
- Check if the String ends with specified suffix in Golang
- How to check String for equality under Unicode case folding in Golang?
- Golang | How to find the index of rune in the string?
- How to check the specified rune in Golang String?
- Golang | Checking the string for the specified regular expression
- Golang | Splitting the string after the specified separator
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.