Skip to content

Commit b3ec179

Browse files
joeybloggsjoeybloggs
authored andcommitted
Merge branch 'decode-encode-all-types'
2 parents 509d4bc + d7ce84e commit b3ec179

File tree

8 files changed

+663
-138
lines changed

8 files changed

+663
-138
lines changed

README.md

Lines changed: 24 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
Package form
22
============
33
<img align="right" src="https://raw.githubusercontent.com/go-playground/form/master/logo.jpg">
4-
![Project status](https://img.shields.io/badge/version-1.10.0-green.svg)
4+
![Project status](https://img.shields.io/badge/version-2.0.0-green.svg)
55
[![Build Status](https://semaphoreci.com/api/v1/joeybloggs/form/branches/master/badge.svg)](https://semaphoreci.com/joeybloggs/form)
66
[![Coverage Status](https://coveralls.io/repos/github/go-playground/form/badge.svg?branch=master)](https://coveralls.io/github/go-playground/form?branch=master)
77
[![Go Report Card](https://goreportcard.com/badge/github.com/go-playground/form)](https://goreportcard.com/report/github.com/go-playground/form)
88
[![GoDoc](https://godoc.org/github.com/go-playground/form?status.svg)](https://godoc.org/github.com/go-playground/form)
99
![License](https://img.shields.io/dub/l/vibe-d.svg)
1010

11-
Package form Decodes url.Values into struct values and Encodes struct values into url.Values.
11+
Package form Decodes url.Values into Go value(s) and Encodes Go value(s) into url.Values.
1212

1313
It has the following features:
1414

@@ -18,6 +18,7 @@ It has the following features:
1818
- Only creates objects as necessary eg. if no `array` or `map` values are passed down, the `array` and `map` are left as their default values in the struct.
1919
- Allows for Custom Type registration.
2020
- Handles time.Time using RFC3339 time format by default, but can easily be changed by registering a Custom Type, see below.
21+
- Handles Encoding & Decoding of almost all Go types eg. can Decode into struct, array, map, int... and Encode a struct, array, map, int...
2122

2223
Common Questions
2324

@@ -260,34 +261,34 @@ Field []*string{nil, nil, &i}
260261

261262
Benchmarks
262263
------
263-
###### Run on MacBook Pro (Retina, 15-inch, Late 2013) 2.6 GHz Intel Core i7 16 GB 1600 MHz DDR3 using Go version go1.6.2 darwin/amd64
264+
###### Run on MacBook Pro (Retina, 15-inch, Late 2013) 2.6 GHz Intel Core i7 16 GB 1600 MHz DDR3 using Go version go1.6.3 darwin/amd64
264265

265266
NOTE: the 1 allocation and B/op in the first 4 decodes is actually the struct allocating when passing it in, so primitives are actually zero allocation.
266267

267268
```go
268269
go test -bench=. -benchmem=true
269270

270271
PASS
271-
BenchmarkSimpleUserDecodeStruct-8 5000000 298 ns/op 64 B/op 1 allocs/op
272-
BenchmarkSimpleUserDecodeStructParallel-8 20000000 91.4 ns/op 64 B/op 1 allocs/op
273-
BenchmarkSimpleUserEncodeStruct-8 2000000 966 ns/op 549 B/op 12 allocs/op
274-
BenchmarkSimpleUserEncodeStructParallel-8 5000000 313 ns/op 549 B/op 12 allocs/op
275-
BenchmarkPrimitivesDecodeStructAllPrimitivesTypes-8 1000000 1010 ns/op 96 B/op 1 allocs/op
276-
BenchmarkPrimitivesDecodeStructAllPrimitivesTypesParallel-8 5000000 285 ns/op 96 B/op 1 allocs/op
277-
BenchmarkPrimitivesEncodeStructAllPrimitivesTypes-8 300000 4718 ns/op 3073 B/op 47 allocs/op
278-
BenchmarkPrimitivesEncodeStructAllPrimitivesTypesParallel-8 1000000 1673 ns/op 3072 B/op 47 allocs/op
279-
BenchmarkComplexArrayDecodeStructAllTypes-8 100000 16145 ns/op 2289 B/op 122 allocs/op
280-
BenchmarkComplexArrayDecodeStructAllTypesParallel-8 300000 4943 ns/op 2291 B/op 122 allocs/op
281-
BenchmarkComplexArrayEncodeStructAllTypes-8 100000 16020 ns/op 7351 B/op 147 allocs/op
282-
BenchmarkComplexArrayEncodeStructAllTypesParallel-8 300000 5129 ns/op 7351 B/op 147 allocs/op
283-
BenchmarkComplexMapDecodeStructAllTypes-8 100000 22933 ns/op 5338 B/op 131 allocs/op
284-
BenchmarkComplexMapDecodeStructAllTypesParallel-8 200000 6366 ns/op 5341 B/op 131 allocs/op
285-
BenchmarkComplexMapEncodeStructAllTypes-8 100000 16861 ns/op 7161 B/op 176 allocs/op
286-
BenchmarkComplexMapEncodeStructAllTypesParallel-8 300000 5159 ns/op 7160 B/op 176 allocs/op
287-
BenchmarkDecodeNestedStruct-8 500000 3482 ns/op 416 B/op 15 allocs/op
288-
BenchmarkDecodeNestedStructParallel-8 2000000 1011 ns/op 416 B/op 15 allocs/op
289-
BenchmarkEncodeNestedStruct-8 1000000 2255 ns/op 768 B/op 17 allocs/op
290-
BenchmarkEncodeNestedStructParallel-8 2000000 738 ns/op 768 B/op 17 allocs/op
272+
BenchmarkSimpleUserDecodeStruct-8 5000000 318 ns/op 64 B/op 1 allocs/op
273+
BenchmarkSimpleUserDecodeStructParallel-8 20000000 95.2 ns/op 64 B/op 1 allocs/op
274+
BenchmarkSimpleUserEncodeStruct-8 1000000 1000 ns/op 549 B/op 12 allocs/op
275+
BenchmarkSimpleUserEncodeStructParallel-8 5000000 325 ns/op 549 B/op 12 allocs/op
276+
BenchmarkPrimitivesDecodeStructAllPrimitivesTypes-8 1000000 1058 ns/op 96 B/op 1 allocs/op
277+
BenchmarkPrimitivesDecodeStructAllPrimitivesTypesParallel-8 5000000 324 ns/op 96 B/op 1 allocs/op
278+
BenchmarkPrimitivesEncodeStructAllPrimitivesTypes-8 300000 4823 ns/op 3073 B/op 47 allocs/op
279+
BenchmarkPrimitivesEncodeStructAllPrimitivesTypesParallel-8 1000000 1732 ns/op 3072 B/op 47 allocs/op
280+
BenchmarkComplexArrayDecodeStructAllTypes-8 100000 16340 ns/op 2289 B/op 122 allocs/op
281+
BenchmarkComplexArrayDecodeStructAllTypesParallel-8 300000 5105 ns/op 2291 B/op 122 allocs/op
282+
BenchmarkComplexArrayEncodeStructAllTypes-8 100000 16343 ns/op 7351 B/op 147 allocs/op
283+
BenchmarkComplexArrayEncodeStructAllTypesParallel-8 300000 5969 ns/op 7351 B/op 147 allocs/op
284+
BenchmarkComplexMapDecodeStructAllTypes-8 100000 21259 ns/op 5338 B/op 131 allocs/op
285+
BenchmarkComplexMapDecodeStructAllTypesParallel-8 200000 7493 ns/op 5342 B/op 131 allocs/op
286+
BenchmarkComplexMapEncodeStructAllTypes-8 100000 17060 ns/op 7161 B/op 176 allocs/op
287+
BenchmarkComplexMapEncodeStructAllTypesParallel-8 300000 6421 ns/op 7161 B/op 176 allocs/op
288+
BenchmarkDecodeNestedStruct-8 300000 3488 ns/op 416 B/op 15 allocs/op
289+
BenchmarkDecodeNestedStructParallel-8 1000000 1203 ns/op 416 B/op 15 allocs/op
290+
BenchmarkEncodeNestedStruct-8 1000000 2286 ns/op 768 B/op 17 allocs/op
291+
BenchmarkEncodeNestedStructParallel-8 2000000 939 ns/op 768 B/op 17 allocs/op
291292
```
292293

293294
Competitor benchmarks can be found [here](https://github.com/go-playground/form/blob/master/benchmarks/benchmarks.md)

0 commit comments

Comments
 (0)