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
+15.7k Golang : Validate hostname
+41.4k Golang : How to count duplicate items in slice/array?
+16.5k CodeIgniter/PHP : Create directory if does not exist example
+17.8k Golang : delete and modify XML file content
+10.5k Golang : cannot assign type int to value (type uint8) in range error
+8.1k Golang : What fmt.Println() can do and println() cannot do
+22.5k Golang : Read directory content with filepath.Walk()
+10.7k RPM : error: db3 error(-30974) from dbenv->failchk: DB_RUNRECOVERY: Fatal error, run database recovery
+21.3k Golang : How to get time zone and load different time zone?
+10.9k Golang : Natural string sorting example
+5k Nginx and PageSpeed build from source CentOS example
+8.3k Golang : Qt splash screen with delay example