Skip to content

Commit

Permalink
fixed all code quality issues
Browse files Browse the repository at this point in the history
  • Loading branch information
hifly81 committed Dec 7, 2023
1 parent e28096a commit 675970e
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
6 changes: 6 additions & 0 deletions pkg/cmd/templateShow.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,13 @@ var templateShowCmd = &cobra.Command{
templateDir := os.ExpandEnv(fmt.Sprintf("%s/%s", constants.JRhome, "templates"))
templatePath := fmt.Sprintf("%s/%s.tpl", templateDir, args[0])
templateScript, err := os.ReadFile(templatePath)
if err != nil {
log.Fatalf("Failed to ReadFile: %s", err)
}
valid, err := isValidTemplate([]byte(templateScript))
if err != nil {
log.Fatalf("Failed to read a template: %s", err)
}
templateString := string(templateScript)

var Reset = "\033[0m"
Expand Down
3 changes: 3 additions & 0 deletions pkg/producers/server/JsonProducer.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ func (c *JsonProducer) Produce(key []byte, value []byte, o interface{}) {
respWriter := o.(http.ResponseWriter)
if string(key) != "null" {
_, err := (respWriter).Write(key)
if err != nil {
log.Println(err.Error())
}
_, err = (respWriter).Write([]byte(","))
if err != nil {
log.Println(err.Error())
Expand Down
8 changes: 4 additions & 4 deletions pkg/types/generateRegistry.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,14 @@ func main() {

var typesList []string
err = filepath.Walk(cwd, func(path string, info os.FileInfo, err error) error {
if !info.IsDir() && isAGoFile(path) && !isAGenerateFile(path) {
if !info.IsDir() && isAGoFile(path) && !isAGenerateFile(path) {
name := strings.Split(filepath.Base(path), ".")

if(! (strings.HasPrefix(name[0], "array_") || strings.HasPrefix(name[0], "map_")) ){
if !(strings.HasPrefix(name[0], "array_") || strings.HasPrefix(name[0], "map_")) {
typesList = append(typesList, name[0])
}else{
} else {
//The naming convention for generated code for Array in gogen-avro is: Array<filename>Wrapper we use Array_<filename>_Wrapper because we use {{camel .}} later in the template
typesList = append(typesList, name[0]+ "_wrapper")
typesList = append(typesList, name[0]+"_wrapper")
}

}
Expand Down

0 comments on commit 675970e

Please sign in to comment.