svelte-go-only Svelte Themes

Svelte Go Only

Experiment with SvelteJS and Golang (with grpc-web)

svelte-go-only

Experiment with SvelteJS and Golang (with grpc-web)

In this project I just want to learn how to use svelte.js / sveltekit and grpc-web using golang.

In this project I experiment a bit with embed also to make an executable that is self-contained (including html/css/js files).

This is heavily inspired by this demo: https://github.com/agrism/grpc-web-svelte

This project consists in a simple seltejs/sveltekit application (client side) that will communicate with the golang web server (server side) using gRPC, it builds a single self-contained executable.

Requirements

To build this project the below software has to be installed:

  • protoc (3.20.1), this package include:
    • protoc-gen-go (generate go files for types from proto files)
    • protoc-gen-js (generate js files for types from proto files)
  • protoc-gen-go-grpc (generate go files for services from proto files), install it with go install google.golang.org/grpc/cmd/protoc-gen-go-grpc
  • protoc-gen-ts (generate js files for service from proto files), install it with npm -g i @safanaj/ts-protoc-gen
  • sponge, utility used in the Makefile

Notes

The output of protoc-gen-js plugin is not ready for es6, so sveltekit and vitejs are not working to generate client-side JS code, for that reason a simple pythong script is provided to consistently "patch" the js files generated by protoc-gen-js.

Build and run

make build
./svelte-go-only

or

make start

Top categories

Loading Svelte Themes