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
+17k Golang : Capture stdout of a child process and act according to the result
+17.7k How to enable MariaDB/MySQL logs ?
+13.4k Golang : Read from buffered reader until specific number of bytes
+8.2k Golang : Metaprogramming example of wrapping a function
+20.1k Golang : Reset or rewind io.Reader or io.Writer
+12.4k Golang : Extract part of string with regular expression
+13.4k Golang : Verify token from Google Authenticator App
+9.4k Golang : Create unique title slugs example
+5.1k Golang : Check if a word is countable or not
+10.1k Golang : Bcrypting password
+4.4k Linux/MacOSX : Search and delete files by extension