samedi 2 février 2019

Is it possible to change the value of os.Args so I can add tests to the CLI that I'm creating?

Is it possible to change the value of os.Args globally in a Golang program? I'm writting a library like Cobra just for fun, and internally I make use of os.Args to parse the command-line arguments. I would like to do that to properly test the parser.

Currently what I am doing is manually changing the internal variable of my package, but that's a bad practice.

Thank you.

Aucun commentaire:

Enregistrer un commentaire