Skip to content

Commit 3a76635

Browse files
committed
improve docs, remove uncommented code
1 parent 3751b5b commit 3a76635

File tree

1 file changed

+13
-17
lines changed

1 file changed

+13
-17
lines changed

binder.go

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ import (
2626
* <Type>s("param", &destination) - (for slices) if parameter values exists then binds it to given destination of that type i.e Int64s(...).
2727
* Must<Type>s("param", &destination) - (for slices) parameter value is required to exist, binds it to given destination of that type i.e MustInt64s(...).
2828
29-
for some slice types `BindWithDelimiter("param", &dest, ",")` supports slitting parameter values before type conversion is done
29+
for some slice types `BindWithDelimiter("param", &dest, ",")` supports splitting parameter values before type conversion is done
3030
i.e. URL `/api/search?id=1,2,3&id=1` can be bind to `[]int64{1,2,3,1}`
3131
3232
`FailFast` flags binder to stop binding after first bind error during binder call chain. Enabled by default.
@@ -642,18 +642,6 @@ func (b *ValueBinder) MustByte(sourceParam string, dest *byte) *ValueBinder {
642642
return b.uintValue(sourceParam, dest, 8, true)
643643
}
644644

645-
//// Bytes binds parameter to slice of byte
646-
//// NB: this will bind multiple query params with (single) integer values i.e. `&b=12&b=10` to `[]byte{12, 10}
647-
//// this will not help you with `b=255254` => to `[]byte{255,254}` use CustomFunc or BindUnmarshaler for that
648-
//func (b *ValueBinder) Bytes(sourceParam string, dest *[]byte) *ValueBinder {
649-
// return b.uintsValue(sourceParam, dest, false)
650-
//}
651-
//
652-
//// MustBytes requires parameter value to exist to be bind to byte slice variable. Returns error when value does not exist
653-
//func (b *ValueBinder) MustBytes(sourceParam string, dest *[]byte) *ValueBinder {
654-
// return b.uintsValue(sourceParam, dest, true)
655-
//}
656-
657645
// Uint binds parameter to uint variable
658646
func (b *ValueBinder) Uint(sourceParam string, dest *uint) *ValueBinder {
659647
return b.uintValue(sourceParam, dest, 0, false)
@@ -1170,16 +1158,24 @@ func (b *ValueBinder) durations(sourceParam string, values []string, dest *[]tim
11701158
}
11711159

11721160
// UnixTime binds parameter to time.Time variable (in local Time corresponding to the given Unix time).
1173-
// NB: value larger than 2147483647 is interpreted as UnixNano (unix time with nanosecond precision) where
1174-
// value last 9 characters (e.g. `999999999`) are nano seconds and everything before them are seconds part.
1161+
// NB: value larger than 2147483647 (max int32, 2038-01-19T03:14:07Z) is interpreted as UnixNano (unix time with nanosecond precision)
1162+
// where value last 9 characters (e.g. `999999999`) are nano seconds and everything before them are seconds part.
1163+
//
1164+
// This means following limitation:
1165+
// 0 - 2147483647 is parsed in range of 1970-01-01T00:00:00.000000000+00:00 to 2038-01-19T03:14:07Z
1166+
// 2147483648 - ... is parsed in range of 1970-01-01T00:00:02.147483648Z to ...
11751167
func (b *ValueBinder) UnixTime(sourceParam string, dest *time.Time) *ValueBinder {
11761168
return b.unixTime(sourceParam, dest, false)
11771169
}
11781170

11791171
// MustUnixTime requires parameter value to exist to be bind to time.Duration variable (in local Time corresponding
11801172
// to the given Unix time). Returns error when value does not exist.
1181-
// NB: value larger than 2147483647 is interpreted as UnixNano (unix time with nanosecond precision) where
1182-
// value last 9 characters (e.g. `999999999`) are nano seconds and everything before them are seconds part.
1173+
// NB: value larger than 2147483647 (max int32, 2038-01-19T03:14:07Z) is interpreted as UnixNano (unix time with nanosecond precision)
1174+
// where value last 9 characters (e.g. `999999999`) are nano seconds and everything before them are seconds part.
1175+
//
1176+
// This means following limitation:
1177+
// 0 - 2147483647 is parsed in range of 1970-01-01T00:00:00.000000000+00:00 to 2038-01-19T03:14:07Z
1178+
// 2147483648 - ... is parsed in range of 1970-01-01T00:00:02.147483648Z to ...
11831179
func (b *ValueBinder) MustUnixTime(sourceParam string, dest *time.Time) *ValueBinder {
11841180
return b.unixTime(sourceParam, dest, true)
11851181
}

0 commit comments

Comments
 (0)