/go-webview2

WebView2 bindings for pure Go, without CGo, based on the webview/webview bindings.

Primary LanguageGoOtherNOASSERTION

Go Go Report Card Go Reference

新增和修改:

  • 增加单实例锁,二开时将已开窗口置顶、居中
  • 增加自动检测系统webview2版本,没有安装时根据提示自动安装(win7+测试正常)
  • 增加弹窗MessageBox

win10以下

  • 默认需要安装webview2组件,文件100M多,离线环境比较麻烦
  • 可使用 https://github.com/mzky/weblink 做双内核客户端解决此问题
  • 双内核版本加上集成的web静态文件,经过upx压缩后约12M左右
    v := webviewloader.GetInstalledWebViewVersion() // 取webView版本
      if v == "" {
         \\使用blink内核
      }
    

go-webview2

This package provides an interface for using the Microsoft Edge WebView2 component with Go. It is based on webview/webview and provides a compatible API.

Please note that this package only supports Windows, since it provides functionality specific to WebView2. If you wish to use this library for Windows, but use webview/webview for all other operating systems, you could use the go-webview-selector package instead. However, you will not be able to use WebView2-specific functionality.

If you wish to build desktop applications in Go using web technologies, please consider Wails. It uses go-webview2 internally on Windows.

Demo

If you are using Windows 10+, the WebView2 runtime should already be installed. If you don't have it installed, you can download and install a copy from Microsoft's website:

WebView2 runtime

After that, you should be able to run go-webview2 directly:

go run ./cmd/demo

This will use go-winloader to load an embedded copy of WebView2Loader.dll. If you want, you can also provide a newer version of WebView2Loader.dll in the DLL search path and it should be picked up instead. It can be acquired from the WebView2 SDK (which is permissively licensed.)