Test Generation for Generic Functions, Code Vision, Improvements for HTTP Client and Docker in GoLand 2022.3 EAP #4
The fourth build of the GoLand 2022.3 EAP is now available!
You can get the EAP build via the Toolbox App, download it from our website, use a snap package (for Ubuntu), or from inside GoLand, select Check IDE updates for Early Access Program in Preferences/Settings | Appearance & Behavior | System Settings | Updates.
Test generation for generic functions
You can now generate tests for functions with generic parameters.
Quick-fix to capitalize type parameters
We now have an inspection which detects lowercase type parameters and a quick-fix to make them uppercase.
By default, the inspection has the No highlighting (fix available) severity level, meaning the relevant code is not highlighted but you will get a quick-fix when you place the caret on a lowercase type parameter and press Alt+Enter (⌥ ⏎).
If you want to change the severity level, highlighting, and scope, go to Preferences/Settings | Editor | Inspections and look for the The type parameter t declared in lower case inspection.
We’ve started implementing the Code vision feature (like the one in Rider). For now, we display the code authors if version control integration is enabled. If you click on a code author’s name, the Annotate with Git blame sidebar opens, letting you see who introduced what changes.
By default, the Code vision metrics in GoLand are shown on the right, but you can change this in Preferences/Settings | Editor | Inlay Hints | Code vision.
In the next steps of this feature’s implementation we will introduce usages displayed near all functions and types that show how many times a function or a type is referenced in the current project.
We also plan to show implementations and all compatible interfaces this way.
The metrics will be interactive – by clicking on them you will be able to navigate to the relevant lines of your code.
Tell us what you think about this feature! Please leave your feedback in the corresponding ticket in our issue tracker or in the comments to this blog post.
Generate go.work using replace directives
You can now generate
go.mod if you have
replace directives there. Place the caret on a
replace directive, press Alt+Enter (⌥ ⏎) to see all available intention actions, and select the Generate ‘go.work’ using ‘replace’ directives quick-fix. After that, a
go.work file will appear in your project.
The underlying inspection that detects replace directives has the Warning severity and highlighting, meaning the relevant code is shown in a yellow box and the yellow warning triangle is shown at the top right corner in the editor window.
There may be no warning, however. If a generated workspace includes Go modules that are not replaced in the original go.mod, the warning is not shown due to possible side effects caused by migration.
To see a detailed description of this inspection, go to Preferences/Settings | Editor | Inspections and look for the Migration to Go workspace is possible inspection.
You can also open the page with the inspection settings via the corresponding quick-fix – press Alt+Enter (⌥ ⏎), navigate to the Generate ‘go.work’ using ‘replace’ directives line without selecting it, and press the right arrow. Then choose Edit inspection profile setting.
The “Receiver names are different” inspection ignores generated code
According to Go recommendations, you should name a type’s receivers consistently. For example, if you call the receiver c in one method, don’t call it cl in another.
That recommendation is not really relevant for generated code. We disabled this inspection for files that contain a comment matching the following regular expression (as per the Go convention):
^// Code generated .* DO NOT EDIT\.$
Code style improvements
The HTTP Client now provides better formatting options for requests with long URLs. You can use the Put query parameters on separate lines intention action to break the query into smaller fragments on different lines.
To control your preferences regarding HTTP request formatting, we’ve implemented the new HTTP Request setting in Settings / Preferences | Editor | Code Style.
The HTTP Client now supports script blocks executed before requests. You can generate some data before request execution and put it in the final request using variables.
There is a quick-fix that will create the boilerplate code for initializing variables.
GoLand now supports Crypto API. You can compute the md5 or sha1 hash values for an HTTP request.
For simple cases, the IDE now features a new set of random variables.
Docker executable from WSL without Docker Desktop
GoLand now supports connections to Docker that run in Windows Subsystem for Linux (WSL). You can set up such a connection in Settings/Preferences | Build, Execution, Deployment | Docker.
New intention action: Pull image
There is now an easy way to pull a required image without running it from
docker-compose.yml. Simply call up the context actions (Alt-Enter / ⌥⏎) on the highlighted image name and then select Pull Docker image.
Support for the .dockerignore file type
We’ve introduced full support for
.dockerignore files, including code highlighting and completion. These files are now taken into account when you build an image from the IDE.
Support for the heredoc format in Dockerfile files
Here documents allow you to redirect subsequent
Dockerfile lines to the input of
COPY commands. GoLand now supports this syntax, so you can use it to generate config files or multiline scripts right in your
Docker connections from Docker Contexts
You can now set up additional Docker connections using Docker Contexts if you already have such settings in your Docker config. You can do so by calling the Add Service context menu in the Services view and selecting Docker Connections From Docker Contexts.
Deprecated Docker Machine removed from the list of supported connections
Since the Docker Machine has been deprecated by Docker, we’ve removed it from the list of connections in Settings/ Preferences | Build, Execution, Deployment | Docker.
If you’re an active Docker Machine user, you can still connect to it with an API URL. You can either get a list of Docker machines and enter the corresponding URL there, or enter the path to the certs folder.
Editing improvements for YAML
There’s a new quick-fix to suppress inspections with a comment in YAML files, including Kubernetes files, OpenAPI specifications, and
We’ve also introduced an option to fold multiline comments that make up a block of 3 or more lines and start with #.
That’s it for today. We would love to hear what you think about our new features. Get in touch with us on Twitter, leave your comments here, open an issue in our tracker, or drop us a message in the Gophers Slack #goland channel. Thanks for reading!