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
+10.9k Golang : Create S3 bucket with official aws-sdk-go package
+7.9k Golang : Handle Palindrome string with case sensitivity and unicode
+7.9k Swift : Convert (cast) String to Float
+15.1k Golang : Get HTTP protocol version example
+6.9k Golang : Find the shortest line of text example
+12k Golang : Decompress zlib file example
+21.5k Golang : GORM create record or insert new record into database example
+4.5k JavaScript : Rounding number to decimal formats to display currency
+25.6k Golang : How to write CSV data to file
+11.8k Golang : Setup API server or gateway with Caddy and http.ListenAndServe() function example
+19.3k Golang : How to count the number of repeated characters in a string?
+7.6k Golang : get the current working directory of a running program