DEV Community

diar
diar

Posted on

Go Interview basic questions

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
Enter fullscreen mode Exit fullscreen mode

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?

Hostinger image

Get n8n VPS hosting 3x cheaper than a cloud solution

Get fast, easy, secure n8n VPS hosting from $4.99/mo at Hostinger. Automate any workflow using a pre-installed n8n application and no-code customization.

Start now

Top comments (0)

The Most Contextual AI Development Assistant

Pieces.app image

Our centralized storage agent works on-device, unifying various developer tools to proactively capture and enrich useful materials, streamline collaboration, and solve complex problems through a contextual understanding of your unique workflow.

👥 Ideal for solo developers, teams, and cross-company projects

Learn more

🌶️ Newest Episode of Leet Heat: A Game Show For Developers!

Contestants face rapid-fire full stack web dev questions. Wrong answers? The spice level goes up. Can they keep cool while eating progressively hotter sauces?

View Episode Post

DEV is partnering to bring live events to the community. Join us or dismiss this billboard if you're not interested. ❤️