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
+4.1k Python : Convert(cast) bytes to string example
+12.9k Golang : How to determine if user agent is a mobile device example
+7.4k Golang : Another camera capture GUI application with GTK and OpenCV
+16.1k Golang : Linked list example
+13.1k Golang : On enumeration
+9.4k Golang : Simple File Server
+4.5k Javascript : Shuffle or randomize array example
+15.5k Golang : Capture stdout of a child process and act according to the result
+9.8k Android Studio : Create custom icons for your application example
+12.6k How to automatically restart your crashed Golang server
+6.3k Javascript : Push notifications to browser with Push.js
+7.7k Golang : Get final balance from bit coin address example