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
+3.9k Javascript : Empty an array example
+22k Golang : Read directory content with filepath.Walk()
+12.4k Golang : zlib compress file example
+14.3k Golang : Convert(cast) int to float example
+19.5k Golang : Append content to a file
+17.3k Convert JSON to CSV in Golang
+12.4k Swift : Convert (cast) Int or int32 value to CGFloat
+29.4k Golang : Get and Set User-Agent examples
+10.3k Android Studio : Checkbox for user to select options example
+21.3k SSL : How to check if current certificate is sha1 or sha2
+6.3k Golang : Spell checking with ispell example
+25.9k Golang : Convert(cast) string to uint8 type and back to string