Skip to content

Simple WebView for Golang, avoiding CGO for Windows.

License

Notifications You must be signed in to change notification settings

inkeliz/gowebview

Repository files navigation

gowebview

GoDoc Go Report Card

A small WebView without CGO, based on webview/webview. The main goal was to avoid CGO and make it possible to embed the DLLs. Instead of relying directly on CGO as webview/webview, the inkeliz/gowebview uses golang.org/x/sys/windows, for Windows.

Why use inkeliz/gowebview?

  • If you like to avoid CGO on Windows.
  • If you like to have a single .exe.
  • If you need support for Darwin/Linux.
  • If you need binds from Javascript to Golang.
  • If you like to use a more battle-tested and stable library.

Getting started

Import the package and start using it:

package main

import "github.com/inkeliz/gowebview"

func main() {
	w, err := gowebview.New(&gowebview.Config{URL: "https://google.com", WindowConfig: &gowebview.WindowConfig{Title: "Hello World"}})
	if err != nil {
		panic(err)
	}

	defer w.Destroy()
	w.Run()
}

It will open the https://google.com webpage, without any additional setup.

TODO

  1. Add support to programmatically allow "locahost connections".

    Currently you must run CheckNetIsolation.exe LoopbackExempt -a -n="Microsoft.Win32WebViewHost_cw5n1h2txyewy" externally.

    DONE. It's now implemented for Windows, if you use Config.TransportConfig{IgnoreNetworkIsolation: true}. You don't need to execute the sofware as admin, it'll be request only when needed.

  2. Improve support for Android (currently it needs Gio)

    Currently it's supported, but needs Gio to works.

  3. Remove dependency of webview.dll by calling WebView2Loader.dll directly.

    Currently, it needs to extract both .dll.

  4. Improve security by restricting where look for DLL.

    Currently gowebview adds a new filepath on %PATH%)

  5. Improve error returns.

    Currently it returns errors directly from os, windows and ioutil libraries.

License

Code is distributed under MIT license, feel free to use it in your proprietary projects as well.

Credits

It's highly based on webview/webview and webview/webview_csharp. The idea of avoid CGO was inspired by Ebiten.