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
+22.8k Golang : How to validate URL the right way
+22.1k Golang : Fix type interface{} has no field or no methods and type assertions example
+13.4k Golang : Get URI segments by number and assign as variable example
+2.6k Java : Get FX sentiment from website example
+5.1k Golang : Selection sort example
+11k Golang : Add ASCII art to command line application launching process
+6.3k Golang : Word limiter example
+6.5k Golang : What fmt.Println() can do and println() cannot do
+3.5k Javascript : How to show different content with noscript?
+33.5k Golang : Upload and download file to/from AWS S3
+10.8k Golang : Save webcamera frames to video file
+8.7k Golang : Sort and reverse sort a slice of integers