1
0
mirror of https://github.com/ipfs/kubo.git synced 2025-08-06 19:44:01 +08:00
Files
kubo/core/commands/internal/slice_util.go
2014-11-18 06:15:00 -08:00

32 lines
573 B
Go

package internal
import (
"io"
u "github.com/jbenet/go-ipfs/util"
)
func CastToReaders(slice []interface{}) ([]io.Reader, error) {
readers := make([]io.Reader, 0)
for _, arg := range slice {
reader, ok := arg.(io.Reader)
if !ok {
return nil, u.ErrCast()
}
readers = append(readers, reader)
}
return readers, nil
}
func CastToStrings(slice []interface{}) ([]string, error) {
strs := make([]string, 0)
for _, maybe := range slice {
str, ok := maybe.(string)
if !ok {
return nil, u.ErrCast()
}
strs = append(strs, str)
}
return strs, nil
}