使用vscode调试wails项目(golang桌面GUI)

server/2024/10/10 23:38:33/

文章目录

  • 安装 Golang 环境
  • 安装 NPM
  • 安装 VSCode
  • 安装 Go 插件
  • 安装 Go 插件依赖工具
  • 安装 Wails
    • 系统检查
  • 准备项目
  • Visual Studio Code 配置安装和构建步骤
  • 参考资料

安装 Golang 环境

访问 golang 官网下载环境安装包:https://go.dev/dl/

安装 NPM

从 Node 下载页面 下载 NPM。 最好使用最新版本,因为这是我们通常会测试的版本。

运行 npm --version 进行验证。

安装 VSCode

VsCode 的安装就更加容易,直接在官网下载软件包按照指引安装即可。

https://code.visualstudio.com/

安装 Go 插件

VSCode 的插件功能中输入 go 关键字,然后找到下图中的插件,并安装。
在这里插入图片描述

安装 Go 插件依赖工具

快捷键 Ctrl + Shift + p 打开命令面板,输入go install tools,选择第一项 Go: install/Update Tools
在这里插入图片描述

在这里插入图片描述

安装 Wails

运行 go install github.com/wailsapp/wails/v2/cmd/wails@latest 安装 Wails CLI。

系统检查

运行 wails doctor 将检查您是否安装了正确的依赖项。 如果没有,它会就缺少的内容提供建议以帮助纠正问题。

准备项目

# 下载项目
git clone https://github.com/obity/hiposter.git
# 进入项目目录
cd hiposter
# 进入项目前端目录
cd frontend
# 安装nodejs依赖
npm install
npm run dev
cd ..
go build -tags dev -gcflags "all=-N -l"
wails dev

在这里插入图片描述

Visual Studio Code 配置安装和构建步骤

mkdir .vscode && touch .vscode/launch.json && touch .vscode/tasks.json

lanuch.json

{// 使用 IntellliSense 来了解可能的属性。// 悬停以查看现有属性的描述。// 更多详情访问:https://go.microsoft.com/fwlink/?linkid=830387"version": "0.2.0","configurations": [{"name": "Wails: Debug myproject","type": "go","request": "launch","mode": "exec","program": "${workspaceFolder}/build/bin/myproject.exe","preLaunchTask": "build","cwd": "${workspaceFolder}","env": {}}]
}

文件tasks.json

{"version": "2.0.0","tasks": [{"label": "ui:install","type": "shell","options": {"cwd": "${workspaceFolder}/frontend"},"presentation": {"clear": true,"panel": "shared","showReuseMessage": false},"isBackground": true,"command": "pnpm","args": ["install"]},{"label": "ui:build","type": "shell","options": {"cwd": "${workspaceFolder}/frontend"},"presentation": {"clear": true,"panel": "shared","showReuseMessage": false},"isBackground": true,"command": "pnpm","args": ["build"]},{"label": "build","type": "shell","options": {"cwd": "${workspaceFolder}"},"command": "go","args": ["build","-tags","dev","-gcflags","all=-N -l","-o","build/bin/myproject.exe"],"dependsOn": ["ui:install","ui:build"]}]
}

vscode调试图片如下
在这里插入图片描述

在这里插入图片描述

参考资料

在 VS Code 中调试
vscode launchjson-attributes
使用 VSCode 开发 Golang 代码,并支持 debug断点调试
wails-v2-examples
wails 手动构建
vscode-go/wiki/debugging
集成开发环境


http://www.ppmy.cn/server/129846.html

相关文章

毕业设计_基于SpringBoot+vue的社区博客系统【源码+SQL+教程+可运行】41002

毕业设计_基于SpringBootvue的社区博客系统【源码SQL教程可运行】41002 下载地址:https://download.csdn.net/download/qq_24428851/89834978 技术栈: graduation_admin 后台管理页面 (vue)graduation_web 前台页面 (vue)graduation_server 后台api (…

Pikachu-Cross-Site Scripting-xss盲打

xss盲打,不是一种漏洞类型,而是一个攻击场景;在前端、或者在当前页面是看不到攻击结果;而是在后端、在别的页面才看到结果。 登陆后台,查看结果;

java和JS 遍历一个Map对象的不同

使用For遍历 let paramMap { key1: "value1", key2: "value2" }; let jsonObject {}; Java JSONObject jsonObject new JSONObject(); for (Map.Entry<String, String> param : paramMap.entrySet()) { jsonObject.put(param.getKey(), para…

WebGIS包括哪些技术栈?怎么学习?

WebGIS&#xff0c;其实是利用Web开发技术结合地理信息系统&#xff08;GIS&#xff09;的产物&#xff0c;它是一种通过Internet实现GIS交互操作和服务的最佳途径。 WebGIS通过图形化界面直观地呈现地理信息和特定数据&#xff0c;具有可扩展性和跨平台性。 它提供交互性&am…

猫头虎分享已解决Bug || AssertionError: Torch not compiled with CUDA enabled 解决方案

&#x1f42f; 猫头虎分享已解决Bug || AssertionError: Torch not compiled with CUDA enabled 解决方案 摘要 今天猫头虎收到粉丝提问&#xff1a;“猫哥&#xff0c;我在使用 PyTorch 进行 AI大模型训练 时&#xff0c;出现了 AssertionError: Torch not compiled with CUD…

高并发处理方案:构建可扩展的系统

在现代互联网应用中&#xff0c;高并发是一个常见的挑战。随着用户数量的增加和业务需求的复杂化&#xff0c;系统需要能够处理大量的并发请求。本文将探讨高并发处理的策略和方案&#xff0c;帮助开发者构建可扩展、稳定的系统。 1. 高并发的定义 高并发通常指的是系统在单位…

【科普】Yarn Berry与npm分别是什么?两者之间有什么异同?

Yarn Berry 和 npm 是两种广泛使用的 JavaScript 包管理工具&#xff0c;它们各自有不同的特点和功能。 Yarn Berry 概述&#xff1a;Yarn Berry 是 Yarn 的新版本&#xff08;Yarn 2.x 及更高版本&#xff09;&#xff0c;引入了许多新特性&#xff0c;如 Plug’n’Play、改…

protobuf之Message

简介 Message是protobuf的消息抽象类&#xff0c;是其它通过protoc生成的自定义消息的基类 结构 #mermaid-svg-u5iAZNpfIH5hQrlP {font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:16px;fill:#333;}#mermaid-svg-u5iAZNpfIH5hQrlP .error-icon{fil…