Is there a way to do Shell Expansion of Program arguments in Goland?

42 Views Asked by At

Say I have a bunch of .txt files, and a go file fn.go to read their name. I can type ./fn *.txt in shell to run fn.go properly (os.Args will include a.txt, b.txt etc due to shell expansion).

However if I set "Program Arugments" to *.txt in goland:

goland screenshot

then this does not work because goland won't do Shell Expansion to expand *.txt to a.txt b.txt which are passed to fn. Is there a workaroud?

I tried search the internet,but no luck

1

There are 1 best solutions below

1
On

You may want to use os.ReadDir() function not to pass all these files as command-line arguments:

files, err := os.ReadDir(".")
...
for _, f := range files {
...
}