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
+8.9k Golang : Handle sub domain with Gin
+12.4k Golang : Arithmetic operation with numerical slices or arrays example
+10.1k Golang : Random Rune generator
+6.2k Golang : Selection sort example
+8.2k Golang: Prevent over writing file with md5 hash
+11.3k Golang : Concatenate (combine) buffer data example
+16.5k Golang : Read integer from file into array
+6k Golang : How to write backslash in string?
+6k Golang : Debug with Godebug
+13.2k Golang : Read from buffered reader until specific number of bytes
+7k Golang : Get Alexa ranking data example
+10k Golang : Find and replace data in all files recursively