The gorilla/schema package is a Go library that converts between structs and form values, enabling bidirectional encoding and decoding of HTML form data. It serves as part of the Gorilla web toolkit and provides a straightforward mechanism for populating Go structs with form submission data and conversely encoding struct contents back into form values.
The package supports a comprehensive range of field types including boolean, floating-point variants, integer variants, strings, unsigned integer variants, structs, pointers to these types, and slices or pointers to slices of supported types. Unsupported types are silently ignored, though the library allows registration of custom types for conversion. Field names in structs can be customized using the "schema" struct tag, and fields can be excluded from processing by using a dash as the tag value.
A notable feature is the ability to set default values during encoding and decoding operations through the "default" tag option. This functionality applies when fields have zero values, pointers are nil, or slices are empty. The default tag option works with boolean, floating-point, integer, unsigned integer, string types, slices of these types, and pointers to these types. The library uses pipe characters to separate multiple values when applying defaults to slices. However, the documentation explicitly notes a limitation with primitive types: since Go assigns default zero values to primitives, the library cannot distinguish between an explicitly provided zero value and an absent value, meaning the default will always be applied in such cases. The recommended workaround is using pointers to these types, which have nil as their zero value, allowing the library to differentiate between missing and zero-valued form fields.
According to GitGenius activity tracking, the repository shows median issue and pull request response latency of 1565.6 hours with a mean of 14467.5 hours across 25 tracked items, indicating variable response times. Bug reports represent the most active issue category with 15 tracked instances, followed by stale issues with 4 instances and questions with 2 instances. The most active contributor tracked is jaitaiwan with 21 events, followed by zak905 with 9 events and lll-lll-lll-lll with 4 events. The repository maintains connections with other projects through overlapping contributors, including golang/go, cloudflare/cloudflare-docs, and tempoxyz/tempo.
The package is classified across multiple domain categories including URL query parameters, form decoding, parameter parsing, HTTP request handling, HTML form parsing, data binding, and web forms processing. It is distributed under a BSD license and maintains continuous integration testing with codecov coverage tracking and godoc documentation. The library addresses the practical need for structured form data handling in Go web applications, providing both encoding and decoding capabilities with customizable field mapping and default value support.