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.4k Golang : GMail API create and send draft with simple upload attachment example
+12.2k Golang : zlib compress file example
+6.8k Golang : Use modern ciphers only in secure connection
+7.3k Golang : How to execute code at certain day, hour and minute?
+8.6k Golang : How to find out similarity between two strings with Jaro-Winkler Distance?
+14.1k Golang : Rename directory
+8.4k Golang : Find network service name from given port and protocol
+27.7k Golang : Change a file last modified date and time
+26.7k PHP : Convert(cast) string to bigInt
+21.6k Golang : Print leading(padding) zero or spaces in fmt.Printf?
+29.8k Get client IP Address in Go
+12.2k Golang : Drop cookie to visitor's browser and http.SetCookie() example