Skip to content

Instantly share code, notes, and snippets.

@spy16
Last active January 14, 2020 14:02
Show Gist options
  • Save spy16/a12fac8d5b318d5285b7d8b56b090627 to your computer and use it in GitHub Desktop.
Save spy16/a12fac8d5b318d5285b7d8b56b090627 to your computer and use it in GitHub Desktop.
Go snippets for copy-pasting.

Go Snippets

  1. Window Using zserge/webview
import (
	"fmt"
	"net/url"

	"github.com/zserge/webview"
)

// Window represents a plot window.
type Window struct {
	view webview.WebView
}

// Show loads given html source and renders the window.
func (win *Window) Show(html string) {
	uri := fmt.Sprintf("data:text/html,%s", url.PathEscape(html))
	win.view = webview.New(webview.Settings{
		Resizable: true,
		URL:       uri,
	})

	win.view.Run()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment