---
title: "Oleksiy (@night-codes) | Hashnode"
description: "Oleksiy (@night-codes) writes on Hashnode. Read their latest articles and follow their work."
url: "https://hashnode.com/@night-codes"
---

@night-codes

# Oleksiy

@night-codes · Joined June 2021

## Comments

[Sayed Alesawy Ah, great, then the question is off the table. Yes, I've now studied the Once.Do implementation, it's fun and seems to be specifically designed to lock other calls until the return from the function happens.](https://hashnode.com/posts/top-5-lessons-i-learned-while-working-with-go-for-two-years/60a8fb2e5379f65d10b5f642/comment/60c653704e04b16f767310ca#reply-60c68e851679ed6f51a286e4)

Reply · Article · Jun 13, 2021 · [Top 5 Lessons I learned while working with Go for two years](https://hashnode.com/posts/top-5-lessons-i-learned-while-working-with-go-for-two-years/60a8fb2e5379f65d10b5f642)

[Sayed Alesawy As far as I understand, in this case sql.Open is just for example, which means there could be any other function with indefinite execution time. I would like to return to the problem stated in paragraph 2 (without init function): ...Consider the case where 2 goroutines are calling the function DBConnection() at the same time. It's possible that the first goroutine reads the value of dbInstance and finds it nil and then proceeds to create a new connection... Does dbOnce.Do block the rest of the function's calls for the execution time, or just let them pass by and return nil?](https://hashnode.com/posts/top-5-lessons-i-learned-while-working-with-go-for-two-years/60a8fb2e5379f65d10b5f642/comment/60c653704e04b16f767310ca#reply-60c659df1679ed6f51a28571)

Reply · Article · Jun 13, 2021 · [Top 5 Lessons I learned while working with Go for two years](https://hashnode.com/posts/top-5-lessons-i-learned-while-working-with-go-for-two-years/60a8fb2e5379f65d10b5f642)

[Is it just me or does sync.Once compound the problem? While &sql.Open(...) is running, all other DBConnection will return nil?](https://hashnode.com/posts/top-5-lessons-i-learned-while-working-with-go-for-two-years/60a8fb2e5379f65d10b5f642/comment/60c653704e04b16f767310ca)

Comment · Article · Jun 13, 2021 · [Top 5 Lessons I learned while working with Go for two years](https://hashnode.com/posts/top-5-lessons-i-learned-while-working-with-go-for-two-years/60a8fb2e5379f65d10b5f642)
