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
+6.7k Mac/Linux/Windows : Get CPU information from command line
+11.4k Swift : Convert (cast) Float to String
+14.4k Golang : Send email with attachment(RFC2822) using Gmail API example
+13.5k Golang : Image to ASCII art example
+9.4k Golang : Read file with ioutil
+10.3k Golang : Generate 403 Forbidden to protect a page or prevent indexing by search engine
+4.8k Google : Block or disable caching of your website content
+17.3k Golang : Linked list example
+6.7k Golang : Pat multiplexer routing example
+9.1k Golang : Apply Histogram Equalization to color images
+15k Golang : How to check if IP address is in range