Golang encoding/json.InvalidUTF8Error type and function example
package encoding/json
Golang encoding/json.InvalidUTF8Error type and function usage example
if err != nil {
switch err.(type) {
case *json.SyntaxError, *json.InvalidUTF8Error:
fmt.Printf("invalid json response: %s\n", err)
default:
fmt.Printf("Error: %s\n", err)
}
Reference :
Advertisement
Something interesting
Tutorials
+6.8k Unix/Linux : How to fix CentOS yum duplicate glibc or device-mapper-libs dependency error?
+7.1k Restart Apache or Nginx web server without password prompt
+26k Golang : Convert IP address string to long ( unsigned 32-bit integer )
+25.4k Golang : Convert long hexadecimal with strconv.ParseUint example
+12.4k Golang : Extract part of string with regular expression
+11.5k Golang : Format numbers to nearest thousands such as kilos millions billions and trillions
+5.6k Golang : Shortening import identifier
+7.4k Golang : Accessing dataframe-go element by row, column and name example
+52.6k Golang : How to get struct field and value by name
+22.1k Golang : Match strings by wildcard patterns with filepath.Match() function
+10.9k Golang : How to transmit update file to client by HTTP request example