Golang strconv.CanBackquote() function example
package strconv
Golang strconv.CanBackquote() function usage example
package main
import (
"fmt"
"strconv"
)
func quote(s string) string {
if strconv.CanBackquote(s) {
return "`" + s + "`"
}
return strconv.Quote(s)
}
func main() {
fmt.Println(quote("abc123")) // can back quote
fmt.Println(quote("a`b")) // cannot back quote
}
Reference :
Advertisement
Something interesting
Tutorials
+21.9k Golang : Use TLS version 1.2 and enforce server security configuration over client
+5.9k Golang : Detect variable or constant type
+4.6k JavaScript : Rounding number to decimal formats to display currency
+21.1k Golang : Get password from console input without echo or masked
+21.5k Golang : How to read float value from standard input ?
+13.4k Golang : Verify token from Google Authenticator App
+10.3k Golang : Wait and sync.WaitGroup example
+6.3k Golang : Selection sort example
+10.1k Golang : Find and replace data in all files recursively
+15k Golang : package is not in GOROOT during compilation
+10.5k Generate Random number with math/rand in Go
+12.7k Golang : Sort and reverse sort a slice of bytes