前言

上篇说到Go+wails的Hello-World程序的环境配置、编译和运行的结果,但是懒人总是会想办法减少自己的工作量,经过研究,可以编写cmd批处理脚本来快速完成编译+运行的过程。

纯Go语言项目
./build
build.cmd

<pre spellcheck="false" class="md-fences md-end-block ty-contain-cm modeLoaded" lang="" cid="n11" mdtype="fences" style="box-sizing: border-box; overflow: visible; font-family: var(--monospace); font-size: 0.9em; display: block; break-inside: avoid; text-align: left; white-space: normal; background-image: inherit; background-position: inherit; background-size: inherit; background-repeat: inherit; background-attachment: inherit; background-origin: inherit; background-clip: inherit; background-color: rgb(248, 248, 248); position: relative !important; border: 1px solid rgb(231, 234, 237); border-radius: 3px; padding: 8px 4px 6px; margin-bottom: 15px; margin-top: 15px; width: inherit; color: rgb(51, 51, 51); font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-style: initial; text-decoration-color: initial;">@echo off
chcp 65001

:: 编译可执行文件
go build -o ./build/test.exe main.go

echo ---------------------- Start ----------------------

:: 运行可执行文件 文件名务必更改
cd build

test.exe

echo ----------------------- End -----------------------</pre>

放在项目根目录,再编辑运行/调试设置,如下图所示。

如此便可直接点击右上角的图标一键编译+运行了。

Wails+Go项目

脚本如下,运行/调试设置同理:

<pre spellcheck="false" class="md-fences md-end-block ty-contain-cm modeLoaded" lang="" cid="n17" mdtype="fences" style="box-sizing: border-box; overflow: visible; font-family: var(--monospace); font-size: 0.9em; display: block; break-inside: avoid; text-align: left; white-space: normal; background-image: inherit; background-position: inherit; background-size: inherit; background-repeat: inherit; background-attachment: inherit; background-origin: inherit; background-clip: inherit; background-color: rgb(248, 248, 248); position: relative !important; border: 1px solid rgb(231, 234, 237); border-radius: 3px; padding: 8px 4px 6px; margin-bottom: 15px; margin-top: 15px; width: inherit; color: rgb(51, 51, 51); font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-style: initial; text-decoration-color: initial;">@echo off

chcp 65001

:: 编译可执行文件
wails build

:: 运行可执行文件 文件名务必更改
cd build

hello-world.exe</pre>


接下来应该是Golang或者前端语言的学习内容了,可能与wails相关性不大,但前后端交互一定会单独出来介绍。