Golang : How to write backslash in string?
Alright, below is a simple tutorial on how to write backslash in Golang. Nothing special, just writing it down here for my own future reference.
Here you go!
package main
import "fmt"
func main() {
fmt.Println("One\\backslash")
fmt.Println("Two\\\\backslashes")
fmt.Println("Space in between two\\ \\backslashes")
}
Output:
One\backslash
Two\\backslashes
Space in between two\ \backslashes
See also : Golang : unknown escape sequence error
By Adam Ng(黃武俊)
IF you gain some knowledge or the information here solved your programming problem. Please consider donating to the less fortunate or some charities that you like. Apart from donation, planting trees, volunteering or reducing your carbon footprint will be great too.
Advertisement
Tutorials
+19.3k Golang : When to use public and private identifier(variable) and how to make the identifier public or private?
+10.1k CodeIgniter : Load different view for mobile devices
+37.7k Upload multiple files with Go
+7.6k Golang : Shuffle strings array
+18.1k Golang : Qt image viewer example
+12.4k Golang : List running EC2 instances and descriptions
+17.6k Golang : Multi threading or run two processes or more example
+12.5k Golang : Validate email address
+12.7k Golang : Drop cookie to visitor's browser and http.SetCookie() example
+9.3k Golang : Write multiple lines or divide string into multiple lines
+8.1k Golang : Trim everything onward after a word
+10.3k Golang : How to tokenize source code with text/scanner package?