vscode详细配置Go语言相关插件

文章目录

vscode详细配置Go语言

1.插件介绍

1.1 BetterCommments

注释友好,可以根据代码重要,来更改颜色,如;

1.2GitGraph

Git提交可视化界面,也非常友好,可以快速查看相关内容。但是我个人建议使用SourceTree和vscode结合起来使用,会更强大。

下载地址:https://www.sourcetreeapp.com/

1.3Go

>go:install/update tools下载Go所需要的包。

1.4GoComment

快捷一键加Go中的注释类似注解。

1.5goctl

go_zero插件。官方地址:https://go-zero.dev/

1.6Lowlight Go Errors

vscode中,if err!=nil{} 代码低亮模式。

1.7Markdown

1.8Material Icon Theme

1.9Preetier

2.0Project Manager

多个项目管理工具,避免来回切换项目。

其它插件




2.settings.json文件

json 复制代码
{
  // UI 相关
  "workbench.colorTheme": "One Dark Pro",
  "workbench.iconTheme": "vscode-icons",
  "workbench.startupEditor": "none",
  "explorer.confirmDelete": false,

  // 编辑器基础设置
  "editor.fontSize": 14,
  "editor.lineHeight": 24,
  "editor.renderWhitespace": "none",
  "editor.tabSize": 2,
  "editor.formatOnSave": true,
  "editor.guides.bracketPairs": true,
  "editor.rulers": [80],
  "editor.fontFamily": "JetBrains Mono,Consolas, 'Courier New', monospace",
  "editor.fontLigatures": true,

  // 文件保存
  "files.autoSave": "afterDelay",
  "files.eol": "\n",

  // Vue 配置
  "[vue]": {
    "editor.defaultFormatter": "Vue.volar"
  },

  // HTML 和 CSS 配置
  "[html]": {
    "editor.defaultFormatter": "vscode.html-language-features"
  },
  "[css]": {
    "editor.defaultFormatter": "esbenp.prettier-vscode"
  },

  // JavaScript/TypeScript 配置
  "[javascript]": {
    "editor.defaultFormatter": "esbenp.prettier-vscode"
  },
  "[typescript]": {
    "editor.defaultFormatter": "esbenp.prettier-vscode"
  },
  "[json]": {
    "editor.defaultFormatter": "esbenp.prettier-vscode"
  },

  // Markdown 配置
  "[markdown]": {
    "diffEditor.ignoreTrimWhitespace": true
  },

  // Git 配置
  "git.autofetch": true,
  "git.confirmSync": false,
  "git.enableSmartCommit": true,
  "git.decorations.enabled": true,

  // Go 配置
  "go.gopath": "C:/Users/xz317/go",
  "go.goroot": "C:/WorkSpace/PluginsAllIn/g/g1.7.0.windows-amd64/go",
  "go.useLanguageServer": true,
  "go.languageServerFlags": [
    "-rpc.trace",
    "-logfile=C:/Users/xz317/AppData/Local/Temp/gopls.log"
  ],
  "go.formatTool": "goimports",
  "go.lintTool": "golangci-lint",
  "go.toolsManagement.autoUpdate": true,
  "go.alternateTools": {

  
  
  },

  // gopls 相关设置
  "gopls": {
    
    "usePlaceholders": true,
    "staticcheck": true,
    "analyses": {
      "fillreturns": true,
      "nonewvars": true,
      "undeclaredname": true,
      "unusedparams": true
    },
    "deepCompletion": true,
    "matcher": "fuzzy",
    "completeUnimported": true,
    "semanticTokens": true,
    "hoverKind": "FullDocumentation",
    "experimentalPostfixCompletions": true
  },

  // Go 代码格式化和导入管理
  "[go]": {
    "editor.formatOnSave": true,
    "editor.codeActionsOnSave": {
      "source.organizeImports": "explicit",
      "source.fixAll": "explicit"
    }
  },

  // 编辑器全局代码操作
  "editor.codeActionsOnSave": {
    "source.organizeImports": "always"
  },

  // Prettier 配置
  "prettier.singleQuote": true,
  "prettier.trailingComma": "all",
  "prettier.semi": true,

  // ESLint 配置
  "eslint.format.enable": true,
  "eslint.validate": [
    "javascript",
    "javascriptreact",
    "typescript",
    "typescriptreact",
    "vue"
  ],

  // YAML 配置
  "yaml.format.enable": true,
  "yaml.validate": true,
  "yaml.schemaStore.enable": true,


  // 其他工具 & 插件
  "Lingma.cloudModelAutoTriggerGenerateLength": "medium",
  "Lingma.cloudModelManualTriggerGenerateLength": "long",

  // 其他全局设置
  "diffEditor.ignoreTrimWhitespace": false,
  "RainbowBrackets.depreciation-notice": false,
  "extensions.ignoreRecommendations": true,

  "auto-rename-tag.activationOnLanguage": [
    "*"
  ],
  "workbench.settings.applyToAllProfiles": [
    "functionTemplate"
  ],
  "functionTemplate": "// ${func_name} \n// @receiver ${receiver_name_type}\n// @param ${param_name_type}\n// @return ${return_name_type}\n// @author ${git_name} \n// @date ${date}",
  "projectManager.openInNewWindowWhenClickingInStatusBar": true,
  "projectManager.sortList": "Path",
  "projectManager.confirmSwitchOnActiveWindow": "always",
  "projectManager.groupList": true,
  "diffEditor.hideUnchangedRegions.enabled": true
}
相关推荐
吐个泡泡v2 小时前
Maven 核心命令详解:compile、exec:java、package 与 IDE Reload 机制深度解析
java·ide·maven·mvn compile
细节处有神明2 小时前
Jupyter 中实现交互式图表:ipywidgets 从入门到部署
ide·python·jupyter
程序员陆通2 小时前
CloudBase AI ToolKit + VSCode Copilot:打造高效智能云端开发新体验
人工智能·vscode·copilot
七七&55614 小时前
2024年08月13日 Go生态洞察:Go 1.23 发布与全面深度解读
开发语言·网络·golang
java坤坤14 小时前
GoLand 项目从 0 到 1:第八天 ——GORM 命名策略陷阱与 Go 项目启动慢问题攻坚
开发语言·后端·golang
元清加油14 小时前
【Golang】:函数和包
服务器·开发语言·网络·后端·网络协议·golang
任磊abc16 小时前
vscode无法检测到typescript环境解决办法
ide·vscode·typescript
hfut028816 小时前
【vscode使用说明】
vscode·编辑器·vim
恋喵大鲤鱼17 小时前
Golang 后台技术面试套题 1
面试·golang
weixin_3077791318 小时前
VS Code配置MinGW64编译GNU 科学库 (GSL)
开发语言·c++·vscode·算法