Golang Questions
Golang Questions
package main
const N = 3
func main ()
m := make(map(int)*int)
for i := 0; i < N; i++ {
m[i] = &i
}
for _, v := range m {
print (*v)
}
}
package main
func f1 () {
defer printIn(“f1-begin”)
f2 ()
defer printIn(“f1-end”)
}
func f2 () {
defer printIn(“f2-begin”)
f3 ()
defer printIn(“f2-end”)
}
func f3 () {
defer printIn(“f3-begin”)
panic (0)
defer printIn(“f3-end”)
}
func main () {
f1 ()
}
4. In the following code there are 2 lines of code that will cause syntax errors. Give your answer as
indicated by D, C, B, A?
package main
func main () {
s := AStructure{}
pointer := &s
f(s) //D
g(s) //C
f(pointer) //B
g(pointer) //A
}