Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Quotes not preserved in flags of type StringToString #390

Open
octachrome opened this issue Oct 8, 2023 · 0 comments
Open

Quotes not preserved in flags of type StringToString #390

octachrome opened this issue Oct 8, 2023 · 0 comments

Comments

@octachrome
Copy link

When the program below is run with go run ./main.go --sts 'key="495"' I get map[string]string{"key":"\"123"}, where only one double quote has been trimmed from the value. I don't see anything in the documentation about quote handling, so I would expect quotes to be preserved here: map[string]string{"key":"\"123\""}.

package main

import (
	"fmt"
	"os"

	"github.com/spf13/pflag"
)

func main() {
	fs := pflag.NewFlagSet("Example", pflag.PanicOnError)
	fs.StringToString("sts", make(map[string]string), "")
	_ = fs.Parse(os.Args)
	sts, err := fs.GetStringToString("sts")
	if err != nil {
		panic(err)
	}
	fmt.Printf("%#v\n", sts)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant