google / go-querystring

go-querystring is Go library for encoding structs into URL query strings.

Home Page:https://pkg.go.dev/github.com/google/go-querystring/query

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Add NOT operator by parameter in query string

hugomcfonseca opened this issue · comments

Hello, I would like to know if it is possible to use NOT operator (!) using this package.

If not, it would be really useful to start providing it. Thanks.

Examples: GET http://localhost/?status!=1

If you just mean including an exclamation point in the mapped URL parameter name, then yes that's possible:

package main

import (
	"github.com/google/go-querystring/query"
)

type Options struct {
	Status int `url:"status!"`
}

func main() {
	v, _ := query.Values(Options{1})
	println(v.Encode())
}

Outputs: status%21=1 (%21 is url encoded exclamation).

I'm going to close this, but if you meant something different, feel free to reopen and let me know.