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
}
相关推荐
子恒20055 小时前
警惕GO的重复初始化
开发语言·后端·云原生·golang
摘取一颗天上星️5 小时前
Jupyter 是什么?基于浏览器的交互式计算环境
ide·chrome·jupyter
iCxhust8 小时前
使用 Visual Studio 创建安装包的完整指南
ide·单片机·嵌入式硬件·microsoft·c#·visual studio
是紫焅呢9 小时前
C函数基础.go
开发语言·后端·青少年编程·golang·学习方法·visual studio code
nuoyigui988912 小时前
visual studio学习250614(编译错误)
ide·学习·visual studio
柯南二号12 小时前
用Go写一个飞书机器人定时发送消息的程序
golang·机器人·飞书
是紫焅呢13 小时前
D包和模块.go
开发语言·后端·golang·学习方法·visual studio code
未来之窗软件服务16 小时前
江西招标专家抽选系统源码解读——东方仙盟——仙盟创梦IDE
ide·仙盟创梦ide·东方仙盟
Code季风1 天前
跨语言RPC:使用Java客户端调用Go服务端的HTTP-RPC服务
java·网络协议·http·rpc·golang
Code季风1 天前
学习 Protobuf:序列化、反序列化及与 JSON 的对比
学习·rpc·golang·json