andygeiss/esp32-transpiler

View on GitHub
transpile/handlers/handleCaseClause.go

Summary

Maintainability
A
0 mins
Test Coverage
package handlers

import (
    "go/ast"
    "strings"
)

func handleCaseClause(cc *ast.CaseClause) string {
    code := "case "
    clauses := make([]string, 0)
    for _, clause := range cc.List {
        clauses = append(clauses, HandleExpr(clause))
    }
    code += strings.Join(clauses, ",")
    code += ":"
    for _, body := range cc.Body {
        code += handleStmt(body)
    }
    return code
}