0

I am trying to convert s := '{"selector:"{"Status":"open"}"}' to type string, as I need to pass this as an argument to a query using GetQueryResult().

I have tried UnescapeString, it only accepts string as argument:

fmt.Println("args " ,html.UnescapeString(s)

but s is a Go rune.

peterSO
  • 158,998
  • 31
  • 281
  • 276
Harshitha C
  • 65
  • 1
  • 8

1 Answers1

4

The Go Programming Language Specification

String literals

Rune literals


Use string raw literal back quotes, not rune literal single quotes.


For example,

package main

import (
    "fmt"
)

func main() {
    s := `{"selector:"{"Status":"open"}"}`
    fmt.Printf("type %T: %s", s, s)
}

Playground: https://play.golang.org/p/lGARb35VHTv

Output:

type string: {"selector:"{"Status":"open"}"}
peterSO
  • 158,998
  • 31
  • 281
  • 276