add YAML serialization for ruleset

This commit is contained in:
Kevin Pham
2023-12-04 19:55:50 -06:00
parent b39955025e
commit 6157d6543f
8 changed files with 238 additions and 38 deletions

View File

@@ -6,6 +6,7 @@ import (
"go/parser"
"go/token"
"io"
"io/fs"
//"io/fs"
"os"
@@ -42,7 +43,7 @@ func responseModCodeGen(dir string) (code string, err error) {
factoryMaps := []string{}
for _, file := range files {
if filepath.Ext(file.Name()) != ".go" {
if !shouldGenCodeFor(file) {
continue
}
@@ -114,7 +115,7 @@ func requestModCodeGen(dir string) (code string, err error) {
factoryMaps := []string{}
for _, file := range files {
if filepath.Ext(file.Name()) != ".go" {
if !shouldGenCodeFor(file) {
continue
}
@@ -158,6 +159,19 @@ func init() {
return code, nil
}
func shouldGenCodeFor(file fs.DirEntry) bool {
if file.IsDir() {
return false
}
if filepath.Ext(file.Name()) != ".go" {
return false
}
if strings.HasSuffix(file.Name(), "_test.go") {
return false
}
return true
}
func main() {
rqmCode, err := requestModCodeGen("../requestmodifiers/")
if err != nil {