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
+12.4k Golang : Get checkbox or extract multipart form data value example
+19.9k Golang : Calculate time different
+24.1k Golang : Calculate percentage change of two values
+10.1k Golang : "https://" not allowed in import path
+12.5k Golang : How to check for empty array string or string?
+3.6k Golang : ROT32768 (rotate by 0x80) UTF-8 strings example
+3k Python : Find out the variable type and determine the type with simple test
+10.5k Golang : How to login and logout with JWT example
+6.9k Golang : Qt get screen resolution and display on center example
+8.4k Generate salted password with OpenSSL example
+4.4k Golang : Find the longest line of text example