MCPcopy Index your code
hub / github.com/derekstavis/go-qs

github.com/derekstavis/go-qs @0.3.0

Chat with this repo
repository ↗ · DeepWiki ↗ · release 0.3.0 ↗ · + Follow
6 symbols 18 edges 4 files 0 documented · 0%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

Guitar String

go-qs

Go port of Rack's query strings

Build Status

This package was written as I haven't found a good package that understands Rack/Rails query string format.

It have been designed to marshal and unmarshal nested query strings from/into map[string]interface{}, inspired on the interface of Go builtin json package.

Compatibility

go-qs is a port of Rack's code. All tests included into test suite are also a port of Rack tests, so this package keeps great compatibility with Rack implementation.

Usage

Unmarshal

To unmarshal query strings to a map[string]interface{}:

package main

import (
  "fmt"
  "github.com/derekstavis/go-qs"
)

query, err := qs.Unmarshal("foo=bar&names[]=foo&names[]=bar")

if err != nil {
  fmt.Printf("%#+v\n", query)
}

The output:

map[string]interface {}{"foo":"bar", "names":[]interface {}{"foo", "bar"}}

Marshal

You can also marshal a map[string]interface{} to a query string:

package main

import (
  "fmt"
  "github.com/derekstavis/go-qs"
)

payload := map[string]interface {}{"foo":"bar", "names":[]interface {}{"foo", "bar"}}

querystring, err := qs.Marshal(payload)

if err != nil {
  fmt.Printf(querystring)
}

The output:

foo=bar&names[]=foo&names[]=bar

License

MIT Copyright (c) 2016 Derek W. Stavis

Core symbols most depended-on inside this repo

Unmarshal
called by 34
unmarshal.go
normalizeParams
called by 1
unmarshal.go
Marshal
called by 1
marshal.go
buildNestedQuery
called by 1
marshal.go

Shape

Function 6

Languages

Go100%

Modules by API surface

unmarshal.go2 symbols
marshal.go2 symbols
unmarshal_test.go1 symbols
marshal_test.go1 symbols

For agents

$ claude mcp add go-qs \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact