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.5k Golang : Check if integer is power of four example
+5.1k Nginx and PageSpeed build from source CentOS example
+12.4k Golang : Find and draw contours with OpenCV example
+6.3k Fix ERROR 2003 (HY000): Can't connect to MySQL server on 'IP address' (111)
+6.3k Golang : Scan forex opportunities by Bollinger bands
+9.2k Golang : Get SPF and DMARC from email headers to fight spam
+7k Golang : Pat multiplexer routing example
+8.4k Golang : Check from web if Go application is running or not
+6.9k Golang : When to use make or new?
+9.7k Golang : Convert(cast) string to int64
+12.8k Golang : Drop cookie to visitor's browser and http.SetCookie() example
+20.1k Golang : Count JSON objects and convert to slice/array