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
+10k Golang : How to get quoted string into another string?
+36.3k Golang : Convert date or time stamp from string to time.Time type
+7.9k Golang : Check from web if Go application is running or not
+31.4k Golang : Get local IP and MAC address
+7k Golang : Gorrila mux.Vars() function example
+7.2k Golang : How to fix html/template : "somefile" is undefined error?
+6.5k Golang : Embedded or data bundling example
+20k Golang : Compare floating-point numbers
+6.8k Golang : Calculate BMI and risk category
+6.2k Golang : How to search a list of records or data structures
+25.2k Golang : Generate MD5 checksum of a file
+13k Golang : Convert(cast) uintptr to string example