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
+7.9k Golang : Take screen shot of browser with JQuery example
+7.3k Python : Fix SyntaxError: Non-ASCII character in file, but no encoding declared
+7.9k Golang : Populate or initialize struct with values example
+5.7k Golang : Check if password length meet the requirement
+17k Golang : Implement getters and setters
+7.2k Golang : Check if integer is power of four example
+10.8k Golang : Convert a rune to unicode style string \u
+15.2k Golang : Send email and SMTP configuration example
+9.5k Golang : Create matrix with Gonum Matrix package example
+9.7k Golang : Fix - does not implement sort.Interface (missing Len method)
+3.9k PHP : Extract part of a string starting from the middle