Hi, I’m HHF.

Goland these practical tricks you may not know yet! Introduces some useful skills in daily development. This article continues with some other useful techniques.

Custom structure Tag

Goland has a nice feature: Tag autocompletion. In struct structures, you can add tags to the structure by typing JSON or XML after the field type.

Goland’s default JSON is all in slide line format. But sometimes there are special needs.

For example: In normal cases, companies have uniform requirements for the return value field of the interface. In most cases, the return value of THE JSON format is mostly a sliding line, but there are also camel’s hump format. If this is the case, how do you adjust tag autocompletion?

In another case, some companies will customize tag fields, which goland certainly does not have built-in. If this is the case and you want the tag to be autocomplete, what do you do?

The code automatically synchronizes the remote server

Goland look at the code is a more comfortable thing, after all, Goland provides a lot of functions, such as: Find Usages, view interface implementation, Debug, etc.

For various reasons, in many cases we need to push the code to a remote server to compile the code. There is always a bit of trouble with packaging or git synchronization. Is there a way to automatically synchronize the code to the remote after modifying it locally?

Goland provides just that.

The go list -m fails

This is usually caused by a failure to download a go.mod dependency. Set Goland’s Goproxy.

Code folding,

My OCD is one of the worst. I especially don’t accept collapsing code.

Goland folds code in three places: import folds, error folds, and String Format folds. How do you close them?

The Project directory automatically selects open files

Looking at the source code, we need to know the directory where the current open file is located, so it is helpful to understand the entire code flow. By default, Goland does not select open files in the Project directory. How do you set it up?

Go Tool Recommendation

  • Golangci – lint a skills Go all chain tool, very useful
  • Gofumpt’s tool for automatically replacing formatting codes has been proven to be successful
  • Json to Go is a chrome extension that automatically converts json or mysql statements into corresponding structs