Commit Graph

15 Commits

Author SHA1 Message Date
Evgenii Stratonikov 3e70cb3062 Implement ToSizeInBytes(E)
Allow to convert string with size units (such as "10kb") to bytes.
This converter is privately used in viper. I think it is great to
allow using it from cast. Compared to viper implementation this one
allows to have single-letter suffixes.

Signed-off-by: Evgenii Stratonikov <stratonikov@runbox.com>
2021-10-07 19:37:11 +03:00
Heewa Barfchin e4dda5f5f1
Add ToTimeInDefaultLocation/E
Go's time parsing uses UTC when the format doesn't have a tiemzone, and
has even weirder behavior when it has a zone name but no numeric offset.
A caller to `cast.ToTime` won't know if the returned time was explicitly
in UTC, or defaulted there, so the caller cannot fix it. These new
functions allow a user to supply a different timezone to default to,
with nil using the local zone.
2021-07-27 13:05:07 +02:00
Theofanis Despoudis 4dd38b8b57 Add support for map of int64 and map of int 2018-10-24 20:00:14 +02:00
Roman Volosatovs acbeb36b90 Add ToDurationSlice() 2017-04-13 11:15:03 +02:00
Cameron Moore d37435d953 Add additional type conversions
Adds float32, uint, uint64, uint32, uint16, and uint8 throughout.

Fixes #33
2017-03-03 22:17:07 +01:00
Cameron Moore 2c719d95d6 Fix gofmt and golint errors 2017-03-03 16:44:53 +01:00
chyeh e4f8127058 Add `ToInt8`, `ToInt16` and `ToInt32` 2017-03-03 15:54:08 +01:00
M@ 60e7a69a42 Add ToBoolSlice()
Fixes #1
2016-09-19 22:26:41 +02:00
Matt Keller 0eed3d1b35 Add a ToInt64() and necessary plumbing 2016-03-14 20:19:19 +01:00
jackspirou 7ed57e5c41 adding ToStringMapStringSlice method 2015-08-03 12:36:12 -04:00
bep 2c4fdb5416 Add ToIntSlice 2015-02-24 12:08:11 -05:00
Chance Zibolski 3cc9db95ac Add ToDuration 2015-02-24 12:07:25 -05:00
bep bbe2d4b35d Add ToStringMapBool
ToStringMapBool is useful for a map of flags in a configuration file.
2014-11-06 11:32:02 +01:00
spf13 99f1223ff6 Adding ToSlice 2014-04-26 16:56:25 -06:00
spf13 6796452c69 initial commit of library & tests 2014-04-05 01:21:52 -04:00