Understanding Structs

https://play.golang.org/p/iHqs7JIygdC

What did I do wrong?

Clicking format tells you the answer in a better understandable way than run does:

prog.go:12:1: expected ‘}’, found ‘func’

This is because go now tries to use func as a field name in the struct, but thats not allowed as func is a reserved keyword.

Just close the struct definition properly, and your program will compile and run.

2 Likes

you forget to close struct body with ‘}’ . after i add this every thing work :slight_smile:

Thanks to both of you. That worked

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.