Utility library for managing the installation of Microsoft's WebView2 runtime
MIT License
This package provides the following capabilities for managing and installing the WebView2 runtime:
The general workflow should be:
GetInstalledVersion()
IsOlderThan()
Please consult the package documentation.
package mypackage
import "github.com/leaanthony/webview2runtime"
func BootstrapRuntime() error {
var err error
shouldInstall := true
message := "The WebView2 runtime is required. Press Ok to install."
installedVersion := webview2runtime.GetInstalledVersion()
if installedVersion != nil {
shouldInstall, err = installedVersion.IsOlderThan("90.0.818.66")
if err != nil {
_ = webview2runtime.Error(err.Error(), "Error")
return err
}
if shouldInstall {
message = "The WebView2 runtime needs updating. Press Ok to install."
}
}
if shouldInstall {
confirmed, err := webview2runtime.Confirm(message, "Missing Requirements")
if err != nil {
return err
}
if confirmed {
installedCorrectly, err := webview2runtime.InstallUsingBootstrapper()
if err != nil {
_ = webview2runtime.Error(err.Error(), "Error")
return err
}
if !installedCorrectly {
err = webview2runtime.Error("The runtime failed to install correctly. Please try again.", "Error")
return err
}
}
}
return nil
}