Debian Codegraph @

_test/issue-1381.go

raw symbols SCIP
1 package main
2
3 import (
4 "bytes"
5 "fmt"
6 )
7
8 func main() {
9 var bufPtrOne *bytes.Buffer
10 var bufPtrTwo *bytes.Buffer
11 var bufPtrThree *bytes.Buffer
12 var bufPtrFour *bytes.Buffer
13
14 for i := 0; i < 2; i++ {
15 bufOne := bytes.Buffer{}
16 bufTwo := &bytes.Buffer{}
17 var bufThree bytes.Buffer
18 bufFour := new(bytes.Buffer)
19
20 if bufPtrOne == nil {
21 bufPtrOne = &bufOne
22 } else if bufPtrOne == &bufOne {
23 fmt.Println("bufOne was not properly redeclared")
24 } else {
25 fmt.Println("bufOne is properly redeclared")
26 }
27
28 if bufPtrTwo == nil {
29 bufPtrTwo = bufTwo
30 } else if bufPtrTwo == bufTwo {
31 fmt.Println("bufTwo was not properly redeclared")
32 } else {
33 fmt.Println("bufTwo is properly redeclared")
34 }
35
36 if bufPtrThree == nil {
37 bufPtrThree = &bufThree
38 } else if bufPtrThree == &bufThree {
39 fmt.Println("bufThree was not properly redeclared")
40 } else {
41 fmt.Println("bufThree is properly redeclared")
42 }
43
44 if bufPtrFour == nil {
45 bufPtrFour = bufFour
46 } else if bufPtrFour == bufFour {
47 fmt.Println("bufFour was not properly redeclared")
48 } else {
49 fmt.Println("bufFour is properly redeclared")
50 }
51 }
52 }
53
54 // Output:
55 // bufOne is properly redeclared
56 // bufTwo is properly redeclared
57 // bufThree is properly redeclared
58 // bufFour is properly redeclared