6cf6f95f58
CodeQL / Analyze (push) Has been cancelled
Sync to Gitee / Run (push) Has been cancelled
Go / build & test (1.25.x) (push) Has been cancelled
Go / build & test (1.26.x) (push) Has been cancelled
Lint / resolve module (push) Has been cancelled
Lint / lint module (push) Has been cancelled
36 lines
552 B
Go
36 lines
552 B
Go
package main
|
|
|
|
import (
|
|
"bytes"
|
|
_ "embed"
|
|
"text/template"
|
|
)
|
|
|
|
//go:embed errorsTemplate.tpl
|
|
var errorsTemplate string
|
|
|
|
type errorInfo struct {
|
|
Name string
|
|
Value string
|
|
HTTPCode int
|
|
CamelValue string
|
|
Comment string
|
|
HasComment bool
|
|
}
|
|
|
|
type errorWrapper struct {
|
|
Errors []*errorInfo
|
|
}
|
|
|
|
func (e *errorWrapper) execute() string {
|
|
buf := new(bytes.Buffer)
|
|
tmpl, err := template.New("errors").Parse(errorsTemplate)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
if err := tmpl.Execute(buf, e); err != nil {
|
|
panic(err)
|
|
}
|
|
return buf.String()
|
|
}
|