1
0
mirror of https://github.com/fumiama/gozel.git synced 2026-06-05 00:10:24 +08:00
Files
gozel/cmd/gen/api.go
fumiama b821801ecd feat(ze): add event support & vadd demo & refactor (#5)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2026-03-28 18:00:12 +08:00

53 lines
739 B
Go

package main
import (
"os"
"path"
)
var apif *os.File
func init() {
f, err := os.Create(path.Join("gozel", "api.go"))
if err != nil {
panic(err)
}
apif = f
apif.WriteString(`// Code generated by cmd/gen. DO NOT EDIT.
/*
*
* Copyright (C) 2026 Fumiama Minamoto
*
* SPDX-License-Identifier: MIT
*
* @file api.go
*
*/
package gozel
import (
"fmt"
"os"
"github.com/fumiama/gozel/internal/zecall"
)
const debug = false
func init() {
`)
}
func addAPI(name string) {
apif.WriteString("\n\tif err := zecall.Register(\"")
apif.WriteString(name)
apif.WriteString("\"); debug && err != nil {\n\t\tfmt.Fprintln(os.Stderr, \"[gozel.warn]\", err)\n\t}\n")
}
func closeAPI() {
apif.WriteString("\n}\n")
apif.Close()
}