Skip to content

Instantly share code, notes, and snippets.

@innomon
Created November 1, 2025 15:09
Show Gist options
  • Save innomon/e9eddc1e014efb5a3c60759d5d39fe9f to your computer and use it in GitHub Desktop.
Save innomon/e9eddc1e014efb5a3c60759d5d39fe9f to your computer and use it in GitHub Desktop.
Simple Go Web Packaging for kiwix-js

A Local Web Server Wrapper for KiWix-js

This is a simple method to embed the KiWix-JS into an executable.

  1. Download and Build KiWix-JS

    git clone [email protected]:kiwix/kiwix-js.git
    cd kiwix-js
    npm install
    npm install rollup --save-dev
    npm run build
  2. Build Executable

copy the go.mod and main.go into the kiwix-js dir

go build -o kiwix-srv
  1. Run Excutable

    ./kiwix-srv

Open the browser and goto kiwiz-js local server

You can also install it on the google cloud run or similar service.

module kiwix
go 1.24.4
package main
import (
"embed"
"flag"
"io/fs"
"log"
"net/http"
)
//go:embed all:dist
var content embed.FS
func main() {
port := flag.String("port", "7070", "Port to serve on")
flag.Parse()
// Use fs.Sub to create a sub-filesystem rooted at the "static" directory.
// This ensures that http.FileServer can correctly find files relative to the base directory.
subFS, err := fs.Sub(content, "dist")
if err != nil {
log.Fatal(err)
}
fs := http.FileServer(http.FS(subFS))
http.Handle("/", fs)
log.Printf("Serving on port %s", *port)
err = http.ListenAndServe(":"+*port, nil)
if err != nil {
log.Fatal(err)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment