I’m trying to run gofmt on all of the .go files in a directory, but not any subdirectories. I have tried using “.” for the target. It does get all of the .go in the current directory, but it also does all the .go files in subdirectories. To be more specific: There is one particular subdirectory which I don’t want it to process: “_Save”.
The https://pkg.go.dev/cmd/go documentation says:
Directory and file names that begin with "." or "_" are ignored by the go tool, as are directories named "testdata".
I have used this in the past and it worked fine. But it doesn’t seem to work now.
Besides “_Save”, I tried “.Save” and even “testdata”. It processed all of them. The command I am using is “gofmt -d .”.
The files in the “_Save” subdirectory are not part of my program’s build, some of them are .go files. There are no references to them in my code, however.
Am I misunderstanding something? Or not doing something correctly?
I’m doing this on Windows 10, by the way.
Thanks,
John
John Souvestre New Orleans LA, USA 504-454-0899
What is TIL?
Installing WSL just to solve this seems like it might be overkill. A for loop in a batch file, or in DOSKEY, would suffice.
From: Jan Mercl <0xj...@gmail.com>
Sent: 2023-09-13, Wed 05:33
To: John Souvestre <jo...@souvestre.com>
Cc: golan...@googlegroups.com
Subject: Re: [go-nuts] How ignore a subdirectory
On Wed, Sep 13, 2023 at 12:25 PM John Souvestre <jo...@souvestre.com> wrote:
You are correct. However, “gofmt .” recurses. It turns out that they handle it differently.
From: golan...@googlegroups.com <golan...@googlegroups.com> On Behalf Of Brian Candler
Sent: 2023-09-13, Wed 07:30
To: golang-nuts <golan...@googlegroups.com>
Subject: Re: [go-nuts] How ignore a subdirectory
I believe that "go fmt ." (note the space after "go") works on the current package only.
--
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...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/cf14f4f9-14fa-495e-905e-d7a62d8c070dn%40googlegroups.com.