Documentation
¶
Overview ¶
Package cast provides helpful functions for casting. It includes casting between different (castable)types for slice.
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func As ¶
As creates new slice instance and casts from elements to result slice. It will return true when from slice is empty.
Example ¶
package main
import (
"fmt"
"github.com/Prastiwar/Go-flow/reflection/cast"
)
func main() {
arr := []interface{}{"1", "2", "3"}
stringArr, ok := cast.As[string](arr)
if !ok {
panic("cannot cast between provided two types")
}
fmt.Println(stringArr)
}
Output: [1 2 3]
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.