Skip to content

sliceconv is a simple go library for converting slices of basic castable types

License

Notifications You must be signed in to change notification settings

Pushwoosh/sliceconv

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Sliceconv

Sliceconv is a go library for converting slices from one type to another.

Integer

Integer converts any integer-based slice to any other integer-based slice. No overflow checks.

func Integer[T1 constraints.Integer, T2 constraints.Integer](from []T1) []T2{}

Float

Float converts any float-based slice to any other float-based slice. No overflow checks.

func Float[T1 constraints.Float, T2 constraints.Float](from []T1) []T2 {}

Examples

Integer

Standard types:

	from := []int32{1, 2, 3}
	to := Integer[int32, int64](from)

User defined types:

	type protoPlatform uint32
	type sdkPlatform uint8
	const (
		IOS sdkPlatform = iota + 1
		Android
		Windows
		Web
	)
	from := []sdkPlatform{IOS, Android, Windows}
	to := Integer[sdkPlatform, protoPlatform](from)

Float

    from := []float32{1.1, 2.2, 3.3}
    to := Float[float32, float64](from)

About

sliceconv is a simple go library for converting slices of basic castable types

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages