MacOS上安装gotk3:
echo ‘export GOPROXY=#39;>>~/.bash-profile
echo ‘export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig’>>~/.bash-profile
echo ‘export GO111MODULE=auto’>>~/.bash-profile
source ~/.bash-profile
安装需要的3个包:
brew install pkg-config gtk+3 adwaita-icon-theme
go get github.com/gotk3/gotk3/gtk
注意:
安装过程中有error 提示的要执行其建议的命令:
brew link –overwrite freetype
#将freetype2 for gtk,作为新的freetype 。旧的软连接要被替换掉。否则,gtk编译时找不到freetype2
使用module模式编译项目,需要在项目目录上及目录下运行:
go mod init <项目名>
以生成go.mod配置文件。
编译运行一个示例代码:
go run test.go