spf13 / spf13/cast

"ToStringSlice" does not support slice of ints?

Open
#88 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Go
Stars
4k
Forks
337
Avg merge
15m
Merged PRs (30d)
1

Description

I was hoping that ToStringSlice would support turning a slice of ints into a slice of strings. Am I wrong in that assumption?

The following fails:

nums := []int{1,2,3,4,5}
out := cast.ToStringSlice(nums)
// expected: []string{"1","2","3","4","5"}
// actual: []

If I use ToStringSliceE I get the error:

unable to cast []int{1, 2, 3, 4, 5} of type []int to []string

Is there a cast method that does what I want that I'm not aware of?

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at the cast.ToStringSlice entry point and reproduce the []int example from the issue. Check how slice inputs are handled and verify that the completed behavior returns []string{"1","2","3","4","5"}, while preserving the existing error-reporting behavior for unsupported inputs.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
tooling
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.