diff --git a/pkg/service/features/variables.feature b/pkg/service/features/variables.feature index cc35fa4..906f435 100644 --- a/pkg/service/features/variables.feature +++ b/pkg/service/features/variables.feature @@ -19,4 +19,23 @@ const int c1 = 4; const int c2 = 5; const double c3 = 5.5; const std::string s1 = "privet"; +``` + + Сценарий: Блок переменных + * Исходник: +``` +package test +var ( + c1 = 4 + c2 = 5 + c3 = 5.5 + s1 = "privet" +) +``` + * Результат: +``` +int c1 = 4; +int c2 = 5; +double c3 = 5.5; +std::string s1 = "privet"; ``` diff --git a/pkg/service/spec.go b/pkg/service/spec.go index 99cb924..29b21eb 100644 --- a/pkg/service/spec.go +++ b/pkg/service/spec.go @@ -21,11 +21,10 @@ func handleGenDecl(decl ast.Decl) string { return code } -func handleSpecs(specs []ast.Spec) string { - code := "" +func handleSpecs(specs []ast.Spec) (code string) { for _, spec := range specs { if InConstBlock { - code += "const" + code += "const " } switch s := spec.(type) { @@ -37,7 +36,7 @@ func handleSpecs(specs []ast.Spec) string { code += handleTypeSpec(spec) } } - return code + return } func handleImportSpec(spec ast.Spec) string { diff --git a/pkg/service/value.go b/pkg/service/value.go index 5441994..1926b03 100644 --- a/pkg/service/value.go +++ b/pkg/service/value.go @@ -35,7 +35,6 @@ func addTypeByValue(s *ast.ValueSpec) (code string) { switch v := value.(type) { case *ast.BasicLit: - code += " " code += handleBasicLitType(v) } return @@ -56,8 +55,7 @@ func handleValueSpecNames(names []*ast.Ident) (code string) { return } -func handleValueSpecType(expr ast.Expr) string { - code := "" +func handleValueSpecType(expr ast.Expr) (code string) { switch t := expr.(type) { case *ast.SelectorExpr: code += handleSelectorExpr(t) @@ -66,7 +64,7 @@ func handleValueSpecType(expr ast.Expr) string { case *ast.StarExpr: code += handleStarExpr(t) } - return code + return } func handleValueSpecValues(values []ast.Expr) string {