What is default value of a global and local variable in go?



What is default value of a global and local variable in go?..

Answer / Prabhanjan Kumar

The default value of an uninitialized global variable in Go is the zero value of its type. For example, for numeric types like int, float, etc., the default value is 0, while for strings it's empty (""). Local variables are not initialized by default and will cause a compile-time error if used before assignment.

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More Go Programming Language Interview Questions

Can we declare a class in go?

1 Answers  


What is the syntax for for-loop in go?

1 Answers  


What is cgo golang?

1 Answers  


Does go support generic programming?

1 Answers  


What is type casting in go programming?

1 Answers  


Why golang is fast?

1 Answers  


What is difference between concurrent and parallel in golang?

1 Answers  


How can you distribute tasks in go to different machines?

1 Answers  


What is a pointer in go?

1 Answers  


List the looping constructs in go language.

1 Answers  


What are the differences in len() and cap() functions of slice in go?

1 Answers  


What is type assertion in go? What does it do?

1 Answers  


Categories