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
+11.7k Use systeminfo to find out installed Windows Hotfix(s) or updates
+35.3k Golang : Upload and download file to/from AWS S3
+6.1k Linux/MacOSX : Search for files by filename and extension with find command
+19.3k Golang : Delete item from slice based on index/key position
+9.5k Golang : How to protect your source code from client, hosting company or hacker?
+11.3k Golang : Calculate Relative Strength Index(RSI) example
+19.5k Golang : Calculate entire request body length during run time
+5.5k Golang : Intercept, inject and replay HTTP traffics from web server
+10.5k Golang : How to check if a website is served via HTTPS
+21.2k Golang : For loop continue,break and range
+8.4k Golang : Get final or effective URL with Request.URL example
+13.7k Golang : Read XML elements data with xml.CharData example