Debian Codegraph @

tests/indent/go.go

raw symbols SCIP
1 package main
2
3 import (
4 "fmt"
5 "strings"
6 )
7
8 type Point struct {
9 X int
10 Y int
11 }
12
13 func compute(a int, b int) int {
14 values := []int{
15 1,
16 2,
17 3,
18 }
19 lookup := map[string]int{
20 "a": 1,
21 "b": 2,
22 }
23 for i, v := range values {
24 if v > a {
25 fmt.Println(i, v)
26 } else {
27 fmt.Println(lookup["a"])
28 }
29 }
30 switch a {
31 case 1:
32 return b
33 case 2:
34 return a
35 default:
36 return 0
37 }
38 }
39
40 func pipe(ch chan int) {
41 select {
42 case msg := <-ch:
43 fmt.Println(msg)
44 default:
45 fmt.Println(strings.TrimSpace("none"))
46 }
47 Loop:
48 for {
49 break Loop
50 }
51 }
52
53 type Shape interface {
54 Area() float64
55 Perimeter() float64
56 }
57
58 type Circle struct {
59 Radius float64
60 }
61
62 func (c Circle) Area() float64 {
63 return 3.14 * c.Radius * c.Radius
64 }
65
66 const (
67 StatusOK = 200
68 StatusError = 500
69 )
70
71 var (
72 count int
73 enabled bool
74 )
75
76 func process(items []int) (int, error) {
77 defer func() {
78 recover()
79 }()
80
81 sum := 0
82 for _, v := range items {
83 switch x := any(v).(type) {
84 case int:
85 sum += x
86 default:
87 continue
88 }
89 }
90
91 go func() {
92 fmt.Println(sum)
93 }()
94
95 point := struct {
96 X, Y int
97 }{
98 X: 1,
99 Y: 2,
100 }
101
102 return point.X, nil
103 }
104
105 func rawString() string {
106 query := `
107 first
108 indented in raw
109 last`
110 return query
111 }