Golang引用webview
package main
import "github.com/zserge/webview"
func main() {
debug := true
w := webview.New(debug)
defer w.Destroy()
w.SetTitle("Minimal webview example")
w.SetSize(800, 600, webview.HintNone)
w.Navigate("https://www.baidu.com")
w.Run()
}
需要先下载http://tdm-gcc.tdragon.net/download,安装,并设置到环境变量才能编译。
编译:go build -ldflags="-H windowsgui" -o webview-example.exe
报错:C:/TDM-GCC-64/bin/../lib/gcc/x86_64-w64-mingw32/9.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: i386 architecture of input file `C:\Users\aa\AppData\Local\Temp\go-link-818186063\000000.o' is incompatible with i386:x86-64 output
C:/TDM-GCC-64/bin/../lib/gcc/x86_64-w64-mingw32/9.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: $WORK\b001\exe\a.out.exe: .rsrc merge failure: corrupt .rsrc section
collect2.exe: error: ld returned 1 exit status
加个参数再编译:go build -ldflags="-H windowsgui -linkmode internal" -o webview-example.exe
编译成功。
运行还需要两个dll:https://github.com/zserge/webview/tree/master/dll