spf13 / spf13/cast

Question: Why not use indirect for map

Open
#105 2 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

package main

import (
	"fmt"
	"github.com/spf13/cast"
)

func main() {
	a := map[string]string{"hello": "123"}

	r := cast.ToStringMapInt(a)
	fmt.Printf("%T %#v\n", r, r)

	r = cast.ToStringMapInt(&a)
	fmt.Printf("%T %#v\n", r, r)
}

//OUTPUT:
//map[string]int map[string]int{"hello":123}
//map[string]int map[string]int{}

If ToStringMapInt does indirect as well, then the ToStringMapInt method will have a friendlier result.

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 ToStringMapInt entry point and inspect how it handles a map pointer compared with a map value. Check the existing conversion behavior for both examples; done means pointer input produces the same converted map result as direct map input, with coverage for the intended behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
tooling
Issue type
Feature
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.