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
+9.1k Golang : How to check if a string with spaces in between is numeric?
+14.6k Golang : Find commonalities in two slices or arrays example
+6k Golang : Process non-XML/JSON formatted ASCII text file example
+13.4k Golang : Query string with space symbol %20 in between
+22.1k Golang : Read directory content with filepath.Walk()
+5.4k Golang : Detect words using using consecutive letters in a given string
+7k CloudFlare : Another way to get visitor's real IP address
+32k Golang : Convert []string to []byte examples
+19k Golang : Execute shell command
+11.1k Use systeminfo to find out installed Windows Hotfix(s) or updates
+5k Golang : Customize scanner.Scanner to treat dash as part of identifier