write base server

This commit is contained in:
2026-09-02 18:16:35 +08:00
parent b4bfb50ae3
commit c4ccba256d
8 changed files with 234 additions and 0 deletions

45
gen/gen.go Normal file
View File

@@ -0,0 +1,45 @@
//go:build ignore
package main
import (
"os"
"path/filepath"
"strings"
"text/template"
)
const tmpl = `// Code generated by gen/gen.go — DO NOT EDIT
package main
import (
{{- range .}}
_ "{{.}}"
{{- end}}
)
`
func main() {
var packages []string
moduleName := "bdgrp_go"
filepath.WalkDir("routes", func(path string, d os.DirEntry, err error) error {
if err != nil || !d.IsDir() || path == "routes" {
return nil
}
entries, _ := os.ReadDir(path)
for _, e := range entries {
if !e.IsDir() && strings.HasSuffix(e.Name(), ".go") {
pkg := moduleName + "/" + filepath.ToSlash(path)
packages = append(packages, pkg)
break
}
}
return nil
})
f, _ := os.Create("routes_gen.go")
defer f.Close()
template.Must(template.New("").Parse(tmpl)).Execute(f, packages)
}