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
}
相关推荐
Tony Bai3 小时前
再见,丑陋的 container/heap!Go 泛型堆 heap/v2 提案解析
开发语言·后端·golang
念何架构之路5 小时前
Go进阶之panic
开发语言·后端·golang
先跑起来再说5 小时前
Git 入门到实战:一篇搞懂安装、命令、远程仓库与 IDEA 集成
ide·git·后端·elasticsearch·golang·intellij-idea
嵌入小生0078 小时前
标准IO---核心函数接口延续(嵌入式Linux)
c语言·vscode·vim·嵌入式·小白·标准io·函数接口
LYOBOYI1238 小时前
vscode界面美化
ide·vscode·编辑器
mailangduoduo12 小时前
零基础教学连接远程服务器部署项目——VScode版本
服务器·pytorch·vscode·深度学习·ssh·gpu算力
Tony Bai14 小时前
“Go 2,请不要发生!”:如果 Go 变成了“缝合怪”,你还会爱它吗?
开发语言·后端·golang
灰子学技术1 天前
go response.Body.close()导致连接异常处理
开发语言·后端·golang
骥龙1 天前
第六篇:AI平台篇 - 从Jupyter Notebook到生产级模型服务
ide·人工智能·jupyter
kun200310291 天前
如何用Obsidian+VSCode生成文案排版并发布到公众号
ide·vscode·编辑器