nintendo switch

Visual Studio Code Golang Problem-solving Guide

Random Thoughts#

I haven't updated my blog for a long time. I'll just write an article using the readme I wrote after remaking the problem-solving repository!

Recently, I plan to get rid of my current Z4 workspace and build a NAS with better performance myself, while also providing an x86 remote development environment for the ARM-based Mac. I might possibly update a series of articles describing my process of tinkering in the near future, so stay tuned!~

Main Text#

Recently, I had the urge to do some problem-solving. When I opened the problem-solving repository with vscode, I found that there were quite a few issues with the previous directory structure:

  1. The folders were in Chinese, which caused go mod to not recognize them (the reason why the unit tests were working fine before was because Goland would copy the tests to a temporary directory with only English characters).
  2. Many of the old problem's built-in data types were not included, causing syntax errors even after renaming the folders and recognizing them correctly.

So I decided to let go of the past and remove all the previous code. The main purpose of this remake is to ensure that:

  1. When opening the problem-solving repository directory, all files can be recognized correctly.
  2. Each file has its own unit test that can be run in batches.


  1. Create a Golang project in the root directory of the project.
     go mod init
  2. Install the vscode-leetcode plugin by labuladong.
  3. Set the problem-solving language to Go and set the file save directory to the project's root directory.
     "leetcode.workspaceFolder": "/Users/amtoaer/Documents/code/go/go-leetcode",
     "leetcode.defaultLanguage": "golang",
  4. Set the specific path for file saving (in English without spaces) and the file template with unit tests.

The existing LeetCode extension does not support using the English name of the problem as a variable, so in order to achieve the effect of using an English path, the translation of the problem needs to be turned off.

 "leetcode.useEndpointTranslation": false,
 "leetcode.filePath": {
     "default": {
     "folder": "${id}.${camelCaseName}",
     "filename": "solution_test.${ext}"
 "leetcode.codeTemplate": "package main\n\nimport (\n\t\"testing\"\n)\n\n${code}\n\nfunc Test(t *testing.T) {\n}",
  1. Gofmt does not limit line length, so there may be lines of code that are too long. Use golines for code formatting instead.
     "editor.formatOnSave": true,
     "go.alternateTools": {
         "customFormatter": "/Users/amtoaer/.go/bin/golines"
     "go.formatTool": "custom"

Here are some screenshots of the problem-solving after configuration:

  1. Problem-solving in the editor

  2. Normal code completion

  3. Running unit tests

  4. Running unit tests in batches

What? You're asking if I wrote the test cases myself?

Of course not! Copilot will do that job for you. Just type assert.Equal, press tab a few times, and you'll have all the test cases!


Ownership of this post data is guaranteed by blockchain and smart contracts to the creator alone.