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
+10.3k Golang : How to flush a channel before the end of program?
+30.6k Golang : Validate email address with regular expression
+11.3k Golang : Covert map/slice/array to JSON or XML format
+16.1k Golang : Multi threading or run two processes or more example
+7k Golang : Append and add item in slice
+28.6k Golang : How to get HTTP request header information?
+4.4k Golang : Detect words using using consecutive letters in a given string
+14.2k Golang : Get checkbox or extract multipart form data value example
+12.7k Golang: Pad right or print ending(suffix) zero or spaces in fmt.Printf example
+5.6k Golang : Humanize and Titleize functions
+8.8k Golang : Test a slice of integers for odd and even numbers
+34k Golang : How to split or chunking a file to smaller pieces?