Your code is incomplete (it's missing all the imports), and "go test" doesn't run your main() function anyway, so it's not going to parse the flags.
But otherwise I think it would be something like this: (single dash, -args not --args) go test . -v -args - -dots https://go.dev/play/p/HFJBO1j54iE On Saturday, 6 May 2023 at 14:02:35 UTC+1 Robert Solomon wrote: > > I have a routine that I want to test, that I have to pass a flag into this > test. This is on Win10 using Go 1.20.4. This code is here: > https://go.dev/play/p/p-YeGDk1KaM > > I want to pass a flag I call dots into the test code for this function. I > tried from within the correct directory > > go test --args -dots > or > go test . --args -dots > > Or from the top of my source tree where the go.mod file is : > > go test .\detox --args -dots > go test .\detox\... --args -dots > > I get an error message saying: > > flag provided but not defined: -dots. > > But that flag does show up when I run the program using the -h flag, and > it works when not in go test mode. > The full pgm is in the link above. > > What am I missing? > > --rob solomon > > PS: a stackoverflow question that's similar to this, from 2014, does not > work for me. > > -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/4ad04b3c-54ee-4cb1-b451-b8a138a16332n%40googlegroups.com.