6.4 KiB
6.4 KiB
GoNetKit
- Go Web App where you can find many usefull IT tools
- These tools should provide simple and nice way for user to get what they need without requiring signing up or sharing details with 3rd parties.
Building a Single-File Executable (Windows & Linux)
This app uses Go's embed package to bundle all static files (web UI, icons, CSS, etc.) into a single executable. You do not need to distribute the web/ folder separately.
- You will need C building package, especially on Windows as this app using SQLITE, if you do not need password pushser, then remove it and you will not need it to make windows built.
- built scripts are in
app_buildfolder, but may need fixing as the app is in development still and I built it on few computers when i have time.
Prerequisites
go mod init gonetkit
go mod tidy
1. Prepare Icons (custom icon Optional)
- Place your tray icon and favicon in
web/icon.pngandweb/favicon.png. - For Windows tray icon, you must use a
.icofile. Use the provided script:
# Convert PNG to ICO (requires Python Pillow)
python web/convert_icon.py web/icon.png web/icon.ico
# using ImageMagick convertor
magick envelope.jpg -define icon:auto-resize=16,32,48,64 favicon.ico
# https://github.com/ImageMagick/ImageMagick/releases
ImageMagick\magick.exe web\icon.png -define icon:auto-resize=16,32,48,64 web\favicon.ico
ImageMagick\magick.exe identify web\favicon.ico
# App Icon:
ImageMagick\magick.exe web\icon.png -resize 256x256 -define icon:format=bmp icon.ico
go install github.com/akavel/rsrc@latest
rsrc -arch amd64 -ico icon.ico -o icon.syso
go clean -cache
- For Linux, PNG is fine for the tray icon.
2. Build for Your Platform
Windows (from Windows PowerShell or Command Prompt):
# PowerShell (set environment variables before the command)
$env:GOOS="windows"; $env:GOARCH="amd64"; go build -ldflags "-H=windowsgui" -o GoNetKit.exe main.go
REM Command Prompt (set environment variables before the command)
set GOOS=windows
set GOARCH=amd64
go build -ldflags "-H=windowsgui" -o GoNetKit.exe main.go
Linux/macOS (from Bash):
# Build 64-bit Linux executable
GOOS=linux GOARCH=amd64 go build -o goNetKit main.go
- The resulting executable contains all static files and icons.
2.1. Add an Icon to the Windows Executable
By default, Go does not embed an icon in the .exe. To add your tray/web icon as the Windows executable icon:
- Install the
rsrctool (one-time):go install github.com/akavel/rsrc@latest - Generate a Windows resource file with your icon:
This creates
rsrc -ico web/icon.ico -o icon.sysoicon.sysoin your project root. Go will automatically include it when building for Windows. - Build your app for Windows (see below for PowerShell/CMD syntax).
2.2. Build for Your Platform
Windows (from Windows PowerShell or Command Prompt):
# PowerShell (set environment variables before the command)
$env:GOOS="windows"; $env:GOARCH="amd64"; go build -ldflags "-H=windowsgui" -o GoNetKit.exe main.go
REM Command Prompt (set environment variables before the command)
set GOOS=windows
set GOARCH=amd64
go build -ldflags "-H=windowsgui" -o GoNetKit.exe main.go
- The
-ldflags "-H=windowsgui"flag prevents a console window from opening when you run the app. - The
icon.sysofile ensures your executable uses the same icon as the tray and web UI.
Linux/macOS (from Bash):
# Build 64-bit Linux executable
GOOS=linux GOARCH=amd64 go build -o goNetKit main.go
- The resulting executable contains all static files and icons.
3. Run the App
- Double-click or run from terminal:
- On Windows:
GoNetKit.exe - On Linux:
./goNetKit
- On Windows:
- The app will start a web server (default: http://localhost:5555) and show a system tray icon.
- Use the tray menu to open the web UI or quit the app.
4. Usage Notes
- All static files (HTML, CSS, JS, icons) are embedded. No need to copy the
web/folder. - For custom icons, always convert to
.icofor Windows tray compatibility. - The favicon is served from the embedded files.
5. Troubleshooting
- If icons do not appear in the tray, ensure you used a
.icofile for Windows. - If you update static files, rebuild the executable to embed the latest changes.
5.1. If the Executable Still Has No Icon
If you followed all steps and the icon still does not appear:
- Check icon.syso location: It must be in the same folder as
main.gowhen you rungo build. - Check for multiple .syso files: Only one
.sysofile should be present in your project root. Delete any others. - Try a different icon: Some ICO files may be malformed or missing required sizes. Use a simple 32x32 or 64x64 PNG, convert again, and re-run
rsrc. - Clear Windows icon cache: Sometimes Windows caches icons. Move the
.exeto a new folder, or restart Explorer. - Verify with Resource Hacker: Download Resource Hacker and open your
.exeto see if the icon is embedded. If not, the build did not pick upicon.syso. - Try building without cross-compiling: If you are cross-compiling, try building directly on Windows.
- Try go build without -ldflags: Rarely, the
-ldflagsflag can interfere. Try building with and without it:go build -o GoNetKit.exe main.go go build -ldflags "-H=windowsgui" -o GoNetKit.exe main.go - Try go generate: If you use
go generate, ensure it does not overwrite or removeicon.syso.
If none of these work, please report your Go version, OS, and the exact steps you used.
Favicon and Tray Icon Support
- The app uses both
favicon.pngandicon.icofor browser and tray compatibility. - The browser will use
icon.icoif available (for Windows/Edge/PWA), andfavicon.pngfor other platforms. - The tray icon is loaded from the embedded
icon.ico. - If you update icons, place the new files in
web/and rebuild.
How to Add or Update Icons
- Place your PNG icon (32x32 or 64x64 recommended) in
web/favicon.png. - Convert it to ICO for Windows tray support:
python web/convert_icon.py web/favicon.png web/icon.ico - Both files must be present in
web/before building.
License
MIT