These are some basic GO questions that I've gathered from the interviews.

I will be posting the questions Post As You Go, where I will gather a post from different interviews that I attend.


  1. What is a string in go?

Beisdes that it is just a built in type
It's immutable.
It supports UTF-8, which means, it supports all the world languages.

  1. The difference between an array and a slice?

Array is fixed size and slices are dynamic which use arrays under the hood, so you can add as many values as you want.

  1. How do you catch a panic?

By using recover.
Although keep in mind that the recover has to be inside of a deferr func.
Since the panic stops the execution, defer is executed if there is a panic.

//... rest of the code
defer func() {
    if r := recover(); r != nil {
        fmt.Println("Recovered in f", r)
    }
}()

//... rest of the code

Normally libraries handle panics in their internal code, but they should always return proper error, so you should never get a panic from modules.

  1. What is the difference between any and interface{}

There is no difference.
any is an alias for interface{}


Thanks for your attention.
Is there anything you would add?