govue-razors

command module
v0.0.0-...-024f28d Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 6, 2022 License: MIT Imports: 11 Imported by: 0

README

govue-razors

A simple example of a full-stack app in Go using embedded Vue.js.

The Go server runs a rudimentary REST API (using gorilla/mux) which returns a list of philosophical razors, and the Vue app calls the API and displays the razors.

Inspired by https://hackandsla.sh/posts/2021-06-18-embed-vuejs-in-go/

Development

Start the Vue service in watch mode:

cd frontend
npm run watch

In a separate terminal window, start the Go app in dev mode (so it can reload the frontend changes):

go run . -dev

General Embedded UI Setup in Go

  • Create your Go project as usual
  • Generate a new Vue project using the Vue CLI
vue create frontend
  • Modify Vue app as needed, then generate assets
cd frontend
npm run build
  • In your Go code, use the embed package to embed and serve the assets (see server.go)
//go:embed frontend/dist
var frontend embed.FS
  • In your Vue app, use axios to call the Go API routes as needed

Author

Tenyo Grozev (tenyo.grozev@gmail.com)

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL