Is it possible to set per-directory extension settings for a VS Code workspace?

Viewed 144

I work with Go code but we have various tags for the main repo I work in, and so I would like to define different tags for different directories (or files) when I test them or they are formatted-on-save.

Here's an simplistic example workspace:

daemon/
  manager.go -> +build !nomanagers
  nomanagersutil.go -> no tags set
cmd/
  client/
    main.go -> +build nomanagers
  server/
    main.go -> +build !nomanagers

This lets me build the cmd/server/main.go with all the code from daemon, but the cmd/client/main.go only with a subset of the code from daemon and is generally a very necessary and useful thing to do for this project I work on.

As such, when I have the daemon/manager.go file open, I would like to have the "build on save" feature not set the tag "nomanagers", but when I am in the cmd/client/main.go file and I use the "build on save" feature, I would like to have the nomanagers tag set to true, as that's how that is built directly.

I can set tags globally for the workspace with the setting

{
  "go.buildTags": "nomanagers"
}

but then when I have the cmd/server/main.go or the daemon/manager.go file open, it won't format / build on save these files.

So, is there a way to set buildTags for Go specifically per file or per directory (or more generally set extensions setting per directory or per file)?

0 Answers
Related