2025-03-07 08:08:39 +01:00
2025-03-07 08:08:39 +01:00
2025-03-07 08:08:39 +01:00
2025-03-07 08:08:39 +01:00
2025-03-07 08:08:39 +01:00
2025-03-07 08:08:39 +01:00
2025-03-07 08:08:39 +01:00
2025-03-07 08:08:39 +01:00
2025-03-07 08:08:39 +01:00
2025-03-07 08:08:39 +01:00
2025-03-07 08:08:39 +01:00
2025-03-07 08:08:39 +01:00
2025-03-07 08:08:39 +01:00
2025-03-07 08:08:39 +01:00

wails template

This is my wails-template i am using for the ICT-Regiomeisterschaften 2025. It uses vanilla svelte with vite in the Frontend. For styling i use Flowbyte and TailwindCSS. I have setup a pipeline to build windows and linux binaries. For windows i have a working installer.

Feel free to use this template on your own. To set it up just run setup.sh. If you're not using gitea you will have to rename the .gitea folder to .github, to use the pipelines.

Enjoy :)

Fixes

X-Compilation

for Windows:

sudo pacman -S mingw-w64-gcc
wails dev # to generate bindings
env GOOS=windows GOARCH=amd64 CGO_ENABLED=1 CC=x86_64-w64-mingw32-gcc CXX=x86_64-w64-mingw32-g++ CGO_CXXFLAGS="-IC:\msys64\mingw64\include" wails build -ldflags '-extldflags "-static"' -skipbindings

Branches:

  • main: in memory
  • gorm-sqlite: gorm with SQLite and one to many association.

Live Development

To run in live development mode, run wails dev in the project directory. This will run a Vite development server that will provide very fast hot reload of your frontend changes. If you want to develop in a browser and have access to your Go methods, there is also a dev server that runs on http://localhost:34115. Connect to this in your browser, and you can call your Go code from devtools.

Building

To build a redistributable, production mode package, use wails build.

Tricks:

Notifications:

err := beeep.Notify("Title", "Content", "path/to/icon.png")
if err != nil {
  // handle error
}

Inputs for date objects

<div class="m-5">
<Label>Start</Label>
<Input
  type="datetime-local"
  value={session.Start.toISOString().slice(0, 16)}
  onchange={(e) => {
    // @ts-ignore
    session.Start = new Date(e.target.value);
  }}
  required
/>

File Selector:

import (
    "os"
    "github.com/wailsapp/wails/v2/pkg/runtime"
)
func (a *App) MakeFile() {
    dirname, _ := os.UserHomeDir()
	str, err := runtime.SaveFileDialog(a.ctx, runtime.SaveDialogOptions{DefaultDirectory: dirname, DefaultFilename: "filename.csv"})
	if err != nil {
		panic(err)
	}
	file, err := os.Create(str)
	if err != nil {
		return
	}
	defer file.Close()
}

Radio button for bool

<script lang="ts">
  let isTeam: bool = $state(0)
  let _isTeam:int = $state(0)
  $effect(() => {
    if (isTeam) {
      _isTeam = 1;
    } else {
      _isTeam = 0;
    }
  });
  $effect(() => {
    if (isTeam != (_isTeam === 1)) {
      isTeam = _isTeam === 1;
    }
  });

</script>



<div class="m-5 grid grid-cols-3">
<Label>Type:</Label>
<Radio
  required
  value={0}
  bind:group={_isTeam}
>Single Player</Radio
>
<Radio required value={1} bind:group={_isTeam}>Team</Radio>
</div>

Description
A library management desktop application. Built quick and dirty training for the ICT-Regios.
Readme 282 KiB
Languages
Svelte 45.8%
JavaScript 19.6%
TypeScript 17.3%
Go 14.2%
Shell 2.2%
Other 0.9%