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.1k Golang : Iterate linked list example
+7.9k Golang : Populate or initialize struct with values example
+13.8k Golang : Basic authentication with .htpasswd file
+18.5k Golang : How to get time from unix nano example
+18.5k Golang : Append content to a file
+29.8k Golang : Convert an image file to []byte
+12.6k Golang : Fix image: unknown format error
+30.9k Golang : Convert []string to []byte examples
+12.7k Golang : How to pass map to html template and access the map's elements
+9.4k Golang : Underscore string example
+4.3k Golang : Qt update UI elements with core.QCoreApplication_ProcessEvents
+6.6k Golang : Generate human readable password