gorilla/schema

Package gorilla/schema fills a struct with form values.

View on GitHub ↗Jump to charts ↓

Summary Information

Updated 29 minutes ago
Added to GitGenius on April 8th, 2021
Created on October 2nd, 2012
Open Issues & Pull Requests: 24 (+0)
Number of forks: 244
Total Stargazers: 1,506 (+0)
Total Subscribers: 26 (+0)

Repository Insights (GitGenius)

Median issue/PR response: 65.2 days
Mean response time: 355.6 days
90th percentile: 1596.9 days
Tracked items: 18

Charts & Analytics

Fetching additional details & charts...

Issue Activity (beta)

Open issues: 13
New in 7 days: 0
Closed in 7 days: 0
Avg open age: 714 days
Stale 30+ days: 13
Stale 90+ days: 13

Recent activity

Opened in 7 days: 0
Closed in 7 days: 0
Comments in 7 days: 0
Events in 7 days: 0

Top labels

  • stale (41)
  • bug (35)
  • enhancement (12)
  • question (9)
  • help wanted (6)
  • discussion (1)
  • waiting on new maintainer (1)

Most active issues this week

No issue events were indexed in the last 7 days.

Detailed Description

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.

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.