-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Dean Karn
committed
Jul 31, 2017
1 parent
920e9aa
commit bee67eb
Showing
9 changed files
with
203 additions
and
73 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
"log" | ||
|
||
"github.com/go-playground/form" | ||
) | ||
|
||
// Test ... | ||
type Test struct { | ||
String string `form:",omitempty"` | ||
Array []string | ||
Map map[string]string | ||
} | ||
|
||
// use a single instance of Encoder, it caches struct info | ||
var encoder *form.Encoder | ||
|
||
func main() { | ||
var t Test | ||
|
||
encoder = form.NewEncoder() | ||
|
||
values, err := encoder.Encode(t) | ||
if err != nil { | ||
log.Panic(err) | ||
} | ||
|
||
fmt.Printf("%#v\n", values) | ||
|
||
t.String = "String Val" | ||
t.Array = []string{"arr1"} | ||
|
||
values, err = encoder.Encode(t) | ||
if err != nil { | ||
log.Panic(err) | ||
} | ||
|
||
fmt.Printf("%#v\n", values) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.