Try setting ""go.testEnvVars"" and "go.toolsEnvVars"
On Sunday, 14 February 2021 at 4:42:06 am UTC+8 michael...@gmail.com wrote: > *(Sorry for posting what is mostly a VSCode question. I've asked it on > StackOverflow without getting any responses. Am reposting here in the hope > that some has already run into this problem and figured out how to deal > with it.)* > > I have a Go project that builds a WebAssembly (WASM) app and a backend > server for it. Both pieces build and run without errors. VSCode, however, > produces an annoying linter error in the WASM app. > > ``` > could not import syscall/js (no required module provides package > "syscall/js") > ``` > > The problem, as I currently understand it, is that VSCode doesn't infer > from the build tags that it should invoke `gopls` with `env GOOS=js > GOARCH=wasm` and that one solution is to set these tags as workspace Go > environment vars. > > The app design, however, relies on providing a common internal package to > both the wasm and the server code so that each side sees some struct > definitions that simplify the interface between them. To that end, the repo > is organized (simplified view) as follows: > > ``` > cmd > ├── internal > │ └── common > │ ├── common.go > │ └── common_test.go > ├── server > │ └── main.go > └── wasm > └── main.go > ``` > > How can I configure VSCode to use `env GOOS=js GOARCH=wasm` when linting > the wasm directory and not for other directories? > > > > > > -- 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/56b1c978-8dc9-4b2e-8b2d-f7558f701e0bn%40googlegroups.com.