Vugu 项目教程
1. 项目的目录结构及介绍
Vugu 项目的目录结构如下:
vugu/
├── cmd/
│ └── vugubuild/
├── devutil/
├── examples/
│ ├── simple/
│ └── todo/
├── internal/
├── vgappconf/
├── vgform/
├── vgrouter/
├── vugu/
├── vugufmt/
├── vugujstest/
├── vugumarkdown/
├── vugures/
├── vugusvg/
├── vugux/
├── .gitignore
├── .golangci.yml
├── .travis.yml
├── CHANGELOG.md
├── CONTRIBUTING.md
├── LICENSE
├── README.md
└── go.mod
目录介绍
cmd/
: 包含 Vugu 构建工具的源代码。devutil/
: 开发工具和辅助脚本。examples/
: 包含一些示例项目,如simple
和todo
。internal/
: 内部使用的包,不对外公开。vgappconf/
: 应用配置相关的包。vgform/
: 表单处理相关的包。vgrouter/
: URL 路由相关的包。vugu/
: Vugu 核心库。vugufmt/
: 格式化工具。vugujstest/
: JavaScript 测试工具。vugumarkdown/
: Markdown 处理工具。vugures/
: 资源处理工具。vugusvg/
: SVG 处理工具。vugux/
: 扩展工具。.gitignore
: Git 忽略文件配置。.golangci.yml
: Go 代码质量检查配置。.travis.yml
: Travis CI 配置。CHANGELOG.md
: 更新日志。CONTRIBUTING.md
: 贡献指南。LICENSE
: 许可证。README.md
: 项目说明文档。go.mod
: Go 模块文件。
2. 项目的启动文件介绍
Vugu 项目的启动文件通常位于 examples/
目录下的示例项目中。以 examples/simple
为例,启动文件为 main.go
。
package main
import (
"log"
"net/http"
"os"
"github.com/vugu/vugu/devutil"
)
func main() {
l := log.New(os.Stderr, "", log.LstdFlags)
wd, _ := os.Getwd()
envPrefix := ""
opts := &devutil.DefaultOptions
opts.Logger = l
opts.EnvPrefix = envPrefix
opts.ContentPath = wd
opts.ModRoot = wd
opts.HTTPListenAddr = ":8844"
opts.NoAssetServer = false
opts.NoHTTPListening = false
opts.NoLoggerOutput = false
opts.NoModInit = false
opts.NoModTidy = false
opts.NoVendor = false
opts.VendorPath = "vendor"
opts.BuildEnv = devutil.BuildEnvDev
opts.BuildDir = "build"
opts.BuildOutputDir = "dist"
opts.BuildOutputPublicDir = "public"
opts.BuildOutputStaticDir = "static"
opts.BuildOutputIndexHTML = "index.html"
opts.BuildOutputMainJS = "main.js"
opts.BuildOutputMainCSS = "main.css"
opts.BuildOutputMainWASM = "main.wasm"
opts.BuildOutputMainWASMJS = "main.wasm.js"
opts.BuildOutputMainWASMSym = "main.wasm.sym"
opts.BuildOutputMainWASMSymJS = "main.wasm.sym.js"
opts.BuildOutputMainWASMSymWASM = "main.wasm.sym.wasm"
opts.BuildOutputMainWASMSymWASMJS = "main.wasm.sym.wasm.js"
opts.BuildOutputMainWASMSymWASMSym = "main.wasm.sym.wasm.sym"
opts.BuildOutputMainW