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
764 Golang : Switch Redis database redis.NewClient
+8.6k Golang : Create matrix with Gonum Matrix package example
+7.6k PHP : Get coordinates latitude/longitude from string
+14.9k Golang : Upload/Receive file progress indicator
+12.2k Golang : Parsing or breaking down URL
+7.8k Golang : Embed secret text string into binary(executable) file
+6.1k Golang : Variadic function arguments sanity check example
+17.7k Golang : Convert date string to variants of time.Time type examples
+4.8k Golang : Combine slices of complex numbers and operation example
+10.2k Golang : Convert IPv4 address to packed 32-bit binary format
+7.9k Golang : Sort and reverse sort a slice of floats
+7.3k Golang : ffmpeg with os/exec.Command() returns non-zero status