window10下go语⾔开发环境搭建,及体验go-zero框架,及解
决commandno。。。
前⾔
go-zero 是⼀个集成了各种⼯程实践的 web 和 rpc 框架。通过弹性设计保障了⼤并发服务端的稳定性,经受了充分的实战检验。
go-zero 包含极简的 API 定义和⽣成⼯具 goctl,可以根据定义的 api ⽂件⼀键⽣成 Go, iOS, Android, Kotlin, Dart, TypeScript,
JavaScript 代码,并可直接运⾏。
这么⽜,怎么不想去试⼀下?!
go语⾔环境搭建
配置GO语⾔环境
新增go的代
理 GOPROXY=goproxy.io,direct,mirrors.aliyun/goproxy/,goproxy,athens.azurefd,g
设置环境变量
环境变量path中添加%GOROOT%\bin;%GOPATH%\bin
关键是go语⾔环境在vscode的配置,如下:
{
"go.goroot": "D:\\go",
"go.gopath": "D:\\go_project",
"go.inferGopath": false,
"go.toolsGopath": "D:\\go_project",
"Level": 0,
"git.autofetch": true,
"terminal.integrated.shell.windows": "", // 也可以使⽤     // "terminal.integrated.shellArgs.windows": [
//    "/k",
//    "D:\\Applications\\Cmder\\"
//  ],
"lorTheme": "Monokai Pro (Filter Machine)",
"workbench.iconTheme": "Monokai Pro (Filter Machine) Icons",
"derControlCharacters": false,
"editor.snippetSuggestions": "top",
"editor.suggest.snippetsPreventQuickSuggestions": true,
"abled": true,
"plorerKind": "external",
"editor.cursorStyle": "block",
"editor.links": false,
"useWheelZoom": true,
"derLineHighlight": "all",
"editor.suggest.shareSuggestSelections": true,
"outline.icons": true,
"search.showLineNumbers": true,
"search.smartCase": true,
// package 查模式
"go.gocodePackageLookupMode": "go",
"go.gotoSymbol.includeGoroot": true,
"go.gotoSymbol.includeImports": true,
// build 相关
"go.buildOnSave": "off",
"go.gocodeAutoBuild": true,
"go.gocodeAutoBuild": true,
"go.installDependenciesWhenBuilding": true,
"go.buildFlags": [],
"go.buildTags": "",
"go.coverOnSingleTest": true,
"go.useCodeSnippetsOnFunctionSuggest": true,
"go.useCodeSnippetsOnFunctionSuggestWithoutType": true,
"go.docsTool": "guru",
"go.formatTool": "goimports",
"go.lintTool": "golangci-lint",
"go.lintOnSave": "package",
windows开发平台"go.lintFlags": [
"--fast"
],
"go.formatFlags": [],
"go.vetFlags": [],
"go.vetOnSave": "package",
"go.generateTestsFlags": [],
"go.liveErrors": {
"enabled": true,
"delay": 500
},
"go.gocodeFlags": [
"-builtin",
"-ignore-case",
"-unimported-packages"
],
"go.enableCodeLens": {
"references": true,
"runtest": true
},
"go.delveConfig": {
"dlvLoadConfig": {
"followPointers": true,
"maxVariableRecurse": 1,
"maxStringLen": 64,
"maxArrayValues": 64,
"maxStructFields": -1
},
"apiVersion": 2,
"showGlobalVariables": true
},
"go.editorContextMenuCommands": {
"toggleTestFile": true,
"addTags": true,
"removeTags": true,
"testAtCursor": true,
"testFile": true,
"testPackage": true,
"generateTestForFunction": true,
"generateTestForFile": true,
"generateTestForPackage": true,
"addImport": true,
"testCoverage": true,
"playground": true,
"debugTestAtCursor": true
},
"go.playground": {
"openbrowser": false,
"share": false,
"run": false
},
"go.addTags": {
"go.addTags": {
"tags": "json",
"options": "json=omitempty",
"promptForTags": true,
"transform": "snakecase"
},
"go.removeTags": {
"tags": "",
"options": "",
"promptForTags": false
},
"[go]": {
"deActionsOnSave": {
"anizeImports": true
},
},
"go.alternateTools": {
"go-langserver": "gopls",
},
"go.useLanguageServer": false,
"go.languageServerFlags": [],
"go.languageServerExperimentalFeatures": {        "format": true,
"autoComplete": true,
"rename": true,
"goToDefinition": true,
"hover": true,
"signatureHelp": true,
"goToTypeDefinition": true,
"goToImplementation": true,
"documentSymbols": true,
"workspaceSymbols": true,
"findReferences": true,
"diagnostics": false
}
}
优秀链接:
克隆go-zero
国内gitee地址:
国外github地址:
学习视频地址:
语雀⽂档资料:
玩goctl⼯具
goctl是go-zero微服务框架下的代码⽣成⼯具,其可以快速提升开发效率,让开发⼈员将时间重点放在业务coding上……
查询很多资料都不说的,不清晰,总是报command not found: goctl错误。
我也是将goctl⼯具安装到$GOPATH/bin⽬录下
环境变量也配置了,最后发现,所有⽹上博客都没有说,把$GOPATH/bin,加⼊系统环境path变量。加⼊以后,重启电脑,就可以正常使⽤goctl⼯具。

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。