Import not recognized: encoding/json/v2 with GOEXPERIMENT=jsonv2 in GoLand

Question

import "encoding/json/v2" is not recognized in the editor even when GOEXPERIMENT=jsonv2 is enabled; the IDE suggests and auto-imports encoding/json instead.

Answer

The encoding/json/v2 package becomes available in both the Go compiler and GoLand only when the jsonv2 experiment is properly enabled as a build tag.

To enable support in GoLand:

  1. Navigate to Settings | Go | Build Tags.
  2. In the Experiments field, enter jsonv2.
  3. Click Apply.

After applying this configuration, import "encoding/json/v2" should be recognized by the IDE, and the auto-import should no longer revert to encoding/json.

If the package is still not recognized after these steps, collect the GoLand build number from Help | About and submit a support request for further assistance.

0 out of 0 found this helpful

Please sign in to leave a comment.

Have more questions?

Submit a request