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
+17.2k Golang : How to make a file read only and set it to writable again?
+10.1k Golang : Select region of interest with mouse click and crop from image
+14k Golang : How to check if your program is running in a terminal
+50.2k Golang : Disable security check for HTTPS(SSL) with bad or expired certificate
+10.1k RPM : error: db3 error(-30974) from dbenv->failchk: DB_RUNRECOVERY: Fatal error, run database recovery
+9.2k Golang : ffmpeg with os/exec.Command() returns non-zero status
+6.8k Nginx : How to block user agent ?
+16.6k Golang : Get number of CPU cores
+19.6k Golang : Reset or rewind io.Reader or io.Writer
+6.7k Golang : How to call function inside template with template.FuncMap
+11.6k Linux : How to install driver for 600Mbps Dual Band Wifi USB Adapter
+25.9k Golang : Calculate future date with time.Add() function