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
+16.2k Golang : How to check if input from os.Args is integer?
+12.4k Golang : 2 dimensional array example
+40.2k Golang : UDP client server read write example
+22.1k Fix "Failed to start php5-fpm.service: Unit php5-fpm.service is masked."
+16.4k Golang : Find out mime type from bytes in buffer
+30.2k Golang : How to declare kilobyte, megabyte, gigabyte, terabyte and so on?
+11.2k Golang : Simple image viewer with Go-GTK
+6.8k Golang : Check if password length meet the requirement
+19.8k Golang : Archive directory with tar and gzip
+12.6k Golang : Arithmetic operation with numerical slices or arrays example
+8.3k Golang : Add build version and other information in executables
+5.9k Cash Flow : 50 days to pay your credit card debt