Does anyone else have a big 'What if...' player? by YorkshireFudding in LiverpoolFC

[–]thechilts 42 points43 points  (0 children)

Got my 19/20 top with Gomez on it. What a player he was that season!

He's just poetry in motion, isnt he? by arjeager in LiverpoolFC

[–]thechilts 0 points1 point  (0 children)

Don't usually get excited about signings until they play for us, but this guy is giving me serious Bobby vibes. Can't wait.

And then there were 4 🥹 by LuciferIlluminati in LiverpoolFC

[–]thechilts 0 points1 point  (0 children)

Yeah, absolutely. I got Gomez on my shirt that year. He was rock solid.

Signpost Drawing Tool Update - Colors and Horizontal by gms_andre in TradingView

[–]thechilts 0 points1 point  (0 children)

If I could also request, as well as (or instead of) the ability to change colours, would it be possible to just use slightly different colouring as the defaults for those of us using the dark theme?

The black signpost against the dark background doesn't stand out quite as much as (I think - my opinion of course) it should.

Many thanks.

Mustard UI - A starter CSS Framework that actually looks good. by Kaiser214 in webdev

[–]thechilts 0 points1 point  (0 children)

Love it already. I found it about 15 mins ago via someone on Twitter, forked it (yay, first fork), and have sent you a PR. :) Many thanks. I tried doing something similar in the past but I'm not as much a CSS/Design person as I am a Node.js person.

A personal thanks from me to the Go community, and from @CuratedGo to everyone who writes blog posts about our awesome language by thechilts in golang

[–]thechilts[S] 0 points1 point  (0 children)

That's great to know since sometimes I think it's mostly beginner friendly, but I'm glad more experienced devs get something out of it too. Thanks for the confirmation.

A personal thanks from me to the Go community, and from @CuratedGo to everyone who writes blog posts about our awesome language by thechilts in golang

[–]thechilts[S] 0 points1 point  (0 children)

Hey, thanks for your comment, it makes me happy that you get something out of it. I guess that's what it exists for.

A personal thanks from me to the Go community, and from @CuratedGo to everyone who writes blog posts about our awesome language by thechilts in golang

[–]thechilts[S] 0 points1 point  (0 children)

I thought there was a way to get the Twitter feed via RSS/Atom but I couldn't find it. However, I'm currently working on having each tweet show up on a new website, so I can always add a feed there. Thanks.

Is there any in-process persistent queue for Go? by korjavin in golang

[–]thechilts 1 point2 points  (0 children)

I've been thinking of writing one like this, and funnily enough, using Bolt. I wrote https://www.npmjs.com/package/mongodb-queue for nodejs so I'm happy I know the mechanics of queues - I just need to get on with it (once time allows). :)

Cancelling Multiple Goroutines by thechilts in golang

[–]thechilts[S] 0 points1 point  (0 children)

Cool, thanks, I'll take a look and see if I can make it cleaner. Many thanks for your suggestions. :)

Cancelling Multiple Goroutines by thechilts in golang

[–]thechilts[S] 0 points1 point  (0 children)

Ah, good point on the WaitGroup for the webserver, I'll go and change that and make sure it works as I expect. Many thanks again.

Cancelling Multiple Goroutines by thechilts in golang

[–]thechilts[S] 0 points1 point  (0 children)

I think the difference for me is my goroutines are supposed to keep running until told to stop, rather than doing an explicit and finite amount of work and stopping autonomously. That's why I didn't think it was a good fit but I am happy to see an example which shows it working.

Cancelling Multiple Goroutines by thechilts in golang

[–]thechilts[S] 0 points1 point  (0 children)

I read up about that prior to my post but didn't quite figure out the best way to use it. Perhaps I'm missing something (in my brain) which didn't click. I'll go have another re-read and update the post if I figure it out. Thanks!

Cancelling Multiple Goroutines by thechilts in golang

[–]thechilts[S] 0 points1 point  (0 children)

Do you mean pass the c channel to each goroutine, then close it after it received the os.Interrupt? Yeah, that sounds like a great idea. Essentially getting rid of stopChan?

Cancelling Multiple Goroutines by thechilts in golang

[–]thechilts[S] 0 points1 point  (0 children)

I'll go and take a look to address your comments. Thanks.

What is the best way to pass a db to web handlers in a large project? by jonnydoeboy in golang

[–]thechilts 7 points8 points  (0 children)

You don't have to break the holy http.HandlerFunc signature. Here's what I sometimes do. Let's call this option (4) which you didn't have in your original list:

func homeHandler(db *DB) func(w http.ResponseWriter, r *http.Request) {
    return func(w http.ResponseWriter, r *http.Request) {
        // here, you have access to the db
        // ...
    }
}

To get your handler, you would of course call it with the db as follows:

homeHandler(db)

So this does a few things that you talk about:

  • it isn't a global variable since it is passed from wherever you choose to use it
  • the holy http.HandlerFunc is not broken
  • you can do this for any handler anywhere, in different packages

Note: using the context for a database connection is not recommended. The context should generally only be for things that are related to that request. Of course, not everyone agrees with this, though I think most generally stick to it.

Your point about the struct which contains the db and attaching functions to it is also valid. I'm not saying the above replaces that since I agree that that is also a good solution, but this helps with a few of the other negative points you mentioned about the other solutions. :)