本仓库提供 GoLand 使用 LeetCode Editor 插件刷 Go 题的推荐配置。
- 插件名称:LeetCode Editor(作者:shuzijun)
- GitHub:https://github.com/shuzijun/leetcode-editor
- JetBrains Marketplace:https://plugins.jetbrains.com/plugin/12132-leetcode-editor
- 打开 GoLand:
Settings → Plugins → Marketplace - 搜索
LeetCode Editor - 点击 Install,重启 GoLand
- 打开
Settings → Tools → LeetCode Plugin:URL:https://leetcode.cn或https://leetcode.comCode Type:GoTemp File Path:本地的 Go 项目目录(上层需要有go.mod)- 登录后即可拉取题目
$!velocityTool.leftPadZeros(${question.frontendQuestionId}, 4)-$!velocityTool.camelCaseName(${question.titleSlug})/$!velocityTool.smallCamelCaseName(${question.titleSlug})
package p$!velocityTool.camelCaseName(${question.titleSlug})
${question.code}
// ---------- 本地补全用,不会提交 ----------
type ListNode struct {
Val int
Next *ListNode
}
type TreeNode struct {
Val int
Left *TreeNode
Right *TreeNode
}
type Node struct {
Val int
Next *Node
Prev *Node
Child *Node
Left *Node
Right *Node
Random *Node
Neighbors []*Node
Children []*Node
}
- 每题一个目录、一个 package,不会互相串。
submit region end之后的类型只用于本地补全和语法检查,不会被提交。Temp File Path上层需要先执行go mod init <模块名>生成go.mod。- 建议在插件设置中开启 Custom code template,再将上面的
CodeFileName/CodeTemplate粘贴进去。