创建 hello
项目
mkdir hello cd hello go mod init example.com/my/hello
修改 go.mod
文件, 添加 nuxui
依赖库
module example.com/my/hello go 1.18 require nuxui.org/nuxui v0.0.5 replace nuxui.org/nuxui v0.0.5 => gitee.com/nuxui/nuxui v0.0.5
更新依赖
go mod tidy
创建 hello.go
并编写
package main import ( "nuxui.org/nuxui/nux" _ "nuxui.org/nuxui/ui" ) func main() {
nux.Run(nux.NewWindow(nux.Attr{
"width": "20%", // screen_width x 20% "height": "2:1", // width : height = 2 : 1 "title": "hello", "content": nux.Attr{
"type": "nuxui.org/nuxui/ui.Text", "text": `Hello nuxui`, }, })) }
编译并运行
go build . && ./hello
结果预览