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
+16.9k Golang : Example for DSA(Digital Signature Algorithm) package functions
+8.7k Golang : Create matrix with Gonum Matrix package example
+29.8k Golang : Integer is between a range
+9.5k Golang : Detect user location with HTML5 geo-location
+6.5k Golang : How to check variable or object type during runtime?
+6.5k Python : Fix SyntaxError: Non-ASCII character in file, but no encoding declared
+15.1k Golang : Find smallest number in array
+4.9k Golang : How to validate ISBN?
+7.4k Golang : How to control fmt or log print format?
+28.5k Golang : Math pow(the power of x^y) example
+8.9k Golang : Web routing/multiplex example
+17.1k Golang : convert int to string