Golang
wails入门系列(一)环境安装与demo
Wails 桌面应用开发框架入门教程,介绍 Go、Node.js 环境配置、Wails 安装与诊断、使用 Vue+TypeScript 模板创建项目以及开发构建流程。
说在前面
- 操作系统:win11
- go版本:1.24.4
- nodejs版本:v22.16.0
- wails版本:v2.10.1
go安装
- 官网 这里 下载安装即可
nodejs
- 官网 这里 下载安装即可
安装wails
- 设置go国内代理
go env -w GOPROXY=https://goproxy.cn - 安装
go install github.com/wailsapp/wails/v2/cmd/wails@latest - 确认安装
C:\Users\Administrator>wails doctor Wails Doctor # Wails Version | v2.10.1 # System ┌───────────────────────────────────────────────────────────────────────────┐ | OS | Windows 10 Pro | | Version | 2009 (Build: 26100) | | ID | 24H2 | | Go Version | go1.24.4 | | Platform | windows | | Architecture | amd64 | | CPU | 13th Gen Intel(R) Core(TM) i5-13600KF | | Memory | 32GB | └───────────────────────────────────────────────────────────────────────────┘ # Dependencies ┌───────────────────────────────────────────────────────┐ | Dependency | Package Name | Status | Version | | WebView2 | N/A | Installed | 137.0.3296.93 | | Nodejs | N/A | Installed | 22.16.0 | | npm | N/A | Installed | 10.9.2 | | *upx | N/A | Available | | | *nsis | N/A | Available | | └─────────────── * - Optional Dependency ───────────────┘ # Diagnosis Optional package(s) installation details: - upx : Available at https://upx.github.io/ - nsis : More info at https://wails.io/docs/guides/windows-installer/ SUCCESS Your system is ready for Wails development! ♥ If Wails is useful to you or your company, please consider sponsoring the project: https://github.com/sponsors/leaanthony
创建项目
- 以前端框架为
vue+typescript为例,创建名为wailsdemo的项目:创建后的项目结构如下:wails init -n wailsdemo -t vue-ts
运行
- 直接执行命令
wails dev
- 编译
默认项目编译后exe文件大小在10MB左右
wails build
在另一台机器运行时,除webview之外的内存占用在5MB左右
虽然说进程本身的占用率不高,但是webview的内存占用量不低