Skip to content

Commit

Permalink
feat(go): multiline & switch-case
Browse files Browse the repository at this point in the history
  • Loading branch information
uchars committed Apr 29, 2023
1 parent 75b3a04 commit b3d17bf
Show file tree
Hide file tree
Showing 2 changed files with 125 additions and 3 deletions.
25 changes: 22 additions & 3 deletions queries/go/context.scm
Original file line number Diff line number Diff line change
@@ -1,9 +1,28 @@
([
(method_declaration)
(function_declaration)
(var_declaration)
(type_declaration)
(import_declaration)
(if_statement)
(const_declaration)
(select_statement)
] @context)

(function_declaration
body: (block (_) @context.end)
) @context

(method_declaration
body: (block (_) @context.end)
) @context

(if_statement
consequence: (block (_) @context.end)
) @context

(for_statement
body: (block (_) @context.end)
) @context

(communication_case
communication: (_)
(_) @context.end
) @context
103 changes: 103 additions & 0 deletions test/test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
import (
"errors"


"fmt"

)

func (r *rect) area(a int,
b int) int {
return r.width * r.height





}

var b
,c
,d int = 1, 2

func foo(a int,
b int) (int,
int) {

i := 1

select {
case msg1 := <-c1:
fmt.Println("received", msg1)
case msg2 := <-c2:




fmt.Println("received", msg2)
}


for n := 0;
n <= 5; n++ {
if num := 9;
num < 0 {
fmt.Println(num, "is negative")





} else if num < 10 {
fmt.Println(num, "has 1 digit")







} else {
fmt.Println(num, "has multiple digits")








}
fmt.Println(n)
}

switch i {
case 1:
fmt.Println("one")
case 2:
fmt.Println("two")
case 3:
fmt.Println("three")






}
}















0 comments on commit b3d17bf

Please sign in to comment.