1
0
mirror of https://github.com/ipfs/kubo.git synced 2025-09-13 17:20:27 +08:00
Files
kubo/core/commands/internal/slice_util.go
Ho-Sheng Hsiao bf22aeec0a Reorged imports from jbenet/go-ipfs to ipfs/go-ipfs
- Modified Godeps/Godeps.json by hand
- [TEST] Updated welcome docs hash to sharness
- [TEST] Updated contact doc
- [TEST] disabled breaking test (t0080-repo refs local)
2015-03-31 12:52:25 -07:00

32 lines
571 B
Go

package internal
import (
"io"
u "github.com/ipfs/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
}