querystringlite

package
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 5, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package querystringlite is a faithful port of Node.js's built-in querystring module for flat (non-nested) query strings.

Parsing splits on "&" and "=", treats "+" as a space, and percent-decodes keys and values. Stringifying percent-encodes keys and values (encoding spaces as "%20", matching Node) and repeats keys for multi-valued entries.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Escape

func Escape(s string) string

Escape percent-encodes s the way Node's querystring.escape does. Spaces are encoded as "%20".

func Parse

func Parse(s string) map[string][]string

Parse parses a URL query string into a map of keys to their values. A key that appears multiple times (as in "a=1&a=3") maps to all of its values in order. A segment without "=" maps the key to a single empty-string value.

func ParseSingle

func ParseSingle(s string) map[string]string

ParseSingle is a convenience wrapper around Parse that keeps only the first value seen for each key.

func Stringify

func Stringify(v map[string][]string) string

Stringify serializes a map of keys to values into a query string. Keys are emitted in sorted order for determinism; multi-valued keys are emitted as repeated "key=value" pairs. A key with no values is omitted.

func StringifySingle

func StringifySingle(v map[string]string) string

StringifySingle is a convenience wrapper around Stringify for maps with a single value per key.

func Unescape

func Unescape(s string) string

Unescape decodes s the way Node's querystring.unescape does: "+" becomes a space and valid "%XX" sequences are percent-decoded. Malformed percent sequences are left as-is (lenient, like Node's fallback behavior).

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL