Closed tyler-c-jones closed 3 months ago
I don't understand. Following code works.
package main
import (
"fmt"
"log"
"github.com/itchyny/gojq"
)
func main() {
query, err := gojq.Parse(`"/health/labs"`)
if err != nil {
log.Fatalln(err)
}
iter := query.Run(nil)
for {
v, ok := iter.Next()
if !ok {
break
}
if err, ok := v.(error); ok {
log.Fatalln(err)
}
fmt.Printf("%#v\n", v)
}
}
oh its because I'm a dummy, and the "
were not in place as they should be. appreciate the response!
I'm hoping to be able to pass a string constant such as
"/health/labs"
as an expression. However this fails withunexpected token "/"
. We are usinggojq
as a way to parse various expressions - in this case a path for an url destination in an email template. We may also pass another expression - in this instance it is a constant.This should be valid
jq
. Here is a sample from jqplay. Note that we are using this in a Go service, not from the CLI. We have attempted both ways of escaping this string in Go (backticks and escaping like//
).