Open-Awesome
CategoriesAlternativesStacksSelf-HostedExplore
Open-Awesome

© 2026 Open-Awesome. Curated for the developer elite.

TermsPrivacyAboutGitHubRSS
  1. Home
  2. Go
  3. form

form

MITGov4.3.0

A Go library for decoding url.Values into Go values and encoding Go values into url.Values with full map and array support.

GitHubGitHub
918 stars48 forks0 contributors

What is form?

Form is a Go library that decodes HTTP form data (url.Values) into Go structs, maps, slices, and other types, and encodes Go values back into url.Values. It solves the problem of manually parsing form submissions and generating query strings by providing a robust, type-safe conversion layer. It handles complex nested structures, custom types, and various array formats out of the box.

Target Audience

Go developers building web applications or APIs that need to process HTML form submissions, parse query parameters, or generate URL-encoded data. It's particularly useful for those working with complex data structures in HTTP handlers.

Value Proposition

Developers choose Form for its comprehensive type support, flexibility with arrays and maps, and performance. Unlike standard Go form parsing, it handles nested structures, custom type registration, and precise slice/array indexing without manual intervention.

Overview

:steam_locomotive: Decodes url.Values into Go value(s) and Encodes Go value(s) into url.Values. Dual Array and Full map support.

Use Cases

Best For

  • Parsing HTML form submissions into Go structs
  • Generating URL query strings from complex Go objects
  • Handling nested and indexed array data in forms
  • Working with maps in form-encoded data
  • Customizing time format parsing in form data
  • Building REST APIs that accept form-encoded requests

Not Ideal For

  • Projects that primarily deal with JSON or XML APIs and rarely handle form-encoded data
  • Teams needing built-in data validation alongside parsing, as Form only handles conversion, not validation
  • Applications relying heavily on types that implement encoding.TextUnmarshaler for custom parsing
  • Simple web forms with flat data where Go's standard net/http form parsing is sufficient without extra dependencies

Pros & Cons

Pros

Dual Array Support

Handles both numbered arrays (e.g., 'Array[0]') and normal arrays with multiple values, providing flexibility in form data formatting without rigid indexing requirements.

Flexible Slice Indexing

Honors specified indices in slices and arrays, expanding dynamically as needed, which prevents errors with sparse data and allows precise control over data placement.

Comprehensive Type Coverage

Supports a wide range of Go types including structs, maps, slices, and primitives, with nesting ad infinitum, making it suitable for complex form structures.

Custom Type Registration

Allows overriding default type handling, such as changing time formats from RFC3339, enabling easy adaptation to specific project requirements.

Cons

No TextUnmarshaler Support

Explicitly does not support encoding.TextUnmarshaler, as admitted in the README, limiting compatibility with custom types that use this standard interface for parsing.

Limited to Form-Encoded Data

Only handles url.Values, so it cannot parse JSON, XML, or other data formats common in modern APIs, requiring separate libraries for mixed data handling.

Additional Dependency Overhead

Introduces a third-party library where simpler, flat forms might be adequately handled by Go's standard library alone, adding unnecessary complexity for basic use cases.

Frequently Asked Questions

Quick Stats

Stars918
Forks48
Contributors0
Open Issues12
Last commit8 months ago
CreatedSince 2016

Tags

#encoder#data-serialization#struct-mapping#form-data#decoding#web-development#form#go#parser

Built With

G
Go

Included in

Go169.1k
Auto-fetched 5 hours ago

Related Projects

nosurfnosurf

CSRF protection middleware for Go.

Stars1,740
Forks127
Last commit1 year ago
csrfcsrf

Package gorilla/csrf provides Cross Site Request Forgery (CSRF) prevention middleware for Go web applications & services 🔒

Stars1,199
Forks169
Last commit1 year ago
httpinhttpin

🍡 HTTP Input for Go - HTTP Request from/to Go Struct (Bi-directional Data Binding between Go Struct and http.Request)

Stars386
Forks28
Last commit1 month ago
conformconform

Trims, sanitizes & scrubs data based on struct tags (go, golang)

Stars324
Forks38
Last commit11 months ago
Community-curated · Updated weekly · 100% open source

Found a gem we're missing?

Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.

Submit a projectStar on GitHub