6
6
//
7
7
// As a simple example:
8
8
//
9
- // type Options struct {
10
- // Query string `url:"q"`
11
- // ShowAll bool `url:"all"`
12
- // Page int `url:"page"`
13
- // }
9
+ // type Options struct {
10
+ // Query string `url:"q"`
11
+ // ShowAll bool `url:"all"`
12
+ // Page int `url:"page"`
13
+ // }
14
14
//
15
- // opt := Options{ "foo", true, 2 }
16
- // v, _ := query.Values(opt)
17
- // fmt.Print(v.Encode()) // will output: "q=foo&all=true&page=2"
15
+ // opt := Options{ "foo", true, 2 }
16
+ // v, _ := query.Values(opt)
17
+ // fmt.Print(v.Encode()) // will output: "q=foo&all=true&page=2"
18
18
//
19
19
// The exact mapping between Go values and url.Values is described in the
20
20
// documentation for the Values() function.
@@ -47,8 +47,8 @@ type Encoder interface {
47
47
//
48
48
// Each exported struct field is encoded as a URL parameter unless
49
49
//
50
- // - the field's tag is "-", or
51
- // - the field is empty and its tag specifies the "omitempty" option
50
+ // - the field's tag is "-", or
51
+ // - the field is empty and its tag specifies the "omitempty" option
52
52
//
53
53
// The empty values are false, 0, any nil pointer or interface value, any array
54
54
// slice, map, or string of length zero, and any type (such as time.Time) that
@@ -59,19 +59,19 @@ type Encoder interface {
59
59
// field's tag value is the key name, followed by an optional comma and
60
60
// options. For example:
61
61
//
62
- // // Field is ignored by this package.
63
- // Field int `url:"-"`
62
+ // // Field is ignored by this package.
63
+ // Field int `url:"-"`
64
64
//
65
- // // Field appears as URL parameter "myName".
66
- // Field int `url:"myName"`
65
+ // // Field appears as URL parameter "myName".
66
+ // Field int `url:"myName"`
67
67
//
68
- // // Field appears as URL parameter "myName" and the field is omitted if
69
- // // its value is empty
70
- // Field int `url:"myName,omitempty"`
68
+ // // Field appears as URL parameter "myName" and the field is omitted if
69
+ // // its value is empty
70
+ // Field int `url:"myName,omitempty"`
71
71
//
72
- // // Field appears as URL parameter "Field" (the default), but the field
73
- // // is skipped if empty. Note the leading comma.
74
- // Field int `url:",omitempty"`
72
+ // // Field appears as URL parameter "Field" (the default), but the field
73
+ // // is skipped if empty. Note the leading comma.
74
+ // Field int `url:",omitempty"`
75
75
//
76
76
// For encoding individual field values, the following type-dependent rules
77
77
// apply:
@@ -88,8 +88,8 @@ type Encoder interface {
88
88
// "url" tag) will use the value of the "layout" tag as a layout passed to
89
89
// time.Format. For example:
90
90
//
91
- // // Encode a time.Time as YYYY-MM-DD
92
- // Field time.Time `layout:"2006-01-02"`
91
+ // // Encode a time.Time as YYYY-MM-DD
92
+ // Field time.Time `layout:"2006-01-02"`
93
93
//
94
94
// Slice and Array values default to encoding as multiple URL values of the
95
95
// same name. Including the "comma" option signals that the field should be
@@ -103,9 +103,9 @@ type Encoder interface {
103
103
// from the "url" tag) will use the value of the "del" tag as the delimiter.
104
104
// For example:
105
105
//
106
- // // Encode a slice of bools as ints ("1" for true, "0" for false),
107
- // // separated by exclamation points "!".
108
- // Field []bool `url:",int" del:"!"`
106
+ // // Encode a slice of bools as ints ("1" for true, "0" for false),
107
+ // // separated by exclamation points "!".
108
+ // Field []bool `url:",int" del:"!"`
109
109
//
110
110
// Anonymous struct fields are usually encoded as if their inner exported
111
111
// fields were fields in the outer struct, subject to the standard Go
@@ -117,7 +117,7 @@ type Encoder interface {
117
117
// Nested structs have their fields processed recursively and are encoded
118
118
// including parent fields in value names for scoping. For example,
119
119
//
120
- // "user[name]=acme&user[addr][postcode]=1234&user[addr][city]=SFO"
120
+ // "user[name]=acme&user[addr][postcode]=1234&user[addr][city]=SFO"
121
121
//
122
122
// All other values are encoded using their default string representation.
123
123
//
0 commit comments