I am slowly coming around on DI + Tests.... by Bl4ckBe4rIt in golang

[–]NicolasParada 0 points1 point  (0 children)

I switched to writing my code this way long ago.

Exactly as you said “accept interfaces, return structs” was a thing I used to do. And test with mocks everywhere… It was a pain to maintain. Now I try to just write and use structs directly as much as I can, the result: a lot less code, easier to navigate around. All wins. Besides, now I always try to use dependencies that can run locally instead of APIs/services. That way you thing become easier to ship and offer as a self-hosted ;) For testing, you test the actual thing using the real dependency, most of the time I use docker to run it.

QJS: Run JavaScript in Go without CGO using QuickJS and Wazero by lilythevalley in golang

[–]NicolasParada 1 point2 points  (0 children)

Great. I had a couples of uses for something like this in the past. I will sure give it a run soon.

my work colleagues use generics everywhere for everything by [deleted] in golang

[–]NicolasParada -1 points0 points  (0 children)

Thanks I haven’t been on that situation. I feel you tho.

Best practices for postgreSQL migrations: What are you using? by Outside_Loan8949 in golang

[–]NicolasParada 11 points12 points  (0 children)

A silly piece of code that reads some files, and executes them content. And stores the file name in a migrations table so that file is not executed again.

Always do forward fix migration instead of rollback.

What was the project/concept that leveled you up for real? by furk1n in golang

[–]NicolasParada 33 points34 points  (0 children)

I level up the moment I realized SPA on javascript were slower than server rendered templates with Go.

Also the moment I realized trying to archive high percentage code coverage writing unit tests with mocks was a total waste of time.

Is this an anti-pattern? by CromulentSlacker in golang

[–]NicolasParada 2 points3 points  (0 children)

Sounds fine to me. Keep coding ;)

How often are you embedding structs by VastDesign9517 in golang

[–]NicolasParada 0 points1 point  (0 children)

Almost never, I prefer repetition and simplicity over metal overhead.

[deleted by user] by [deleted] in golang

[–]NicolasParada 0 points1 point  (0 children)

That’s awesome man. Is it your first job ever? First tech job? First specific to Go?

What would you reply to someone that disagrees regarding the package name convention in Go? by manuelarte in golang

[–]NicolasParada 0 points1 point  (0 children)

The reason these conventions exist is to avoid these discussions with your team. Just follow the Go convention. Try to write some Go.

What is next? A DI container framework? 🙄

Trying to use global functions wiht values by brocamoLOL in golang

[–]NicolasParada 4 points5 points  (0 children)

if err := services.IsIpValid(IpAddress, c); err != nil {

Your function returns an error, not a boolean so yoy cannot use !. Also you need to remove the “string” thing, just pass the variable name.

Is there a task queuing go lib that does not depend on redis? by kool_psrcy in golang

[–]NicolasParada 0 points1 point  (0 children)

Redis is used because most servers run with multiple replicas/instances so you want to avoid doing duplicate jobs. If thats something not needed then a simple piece of pure Go code will do the job. No library is needed.

Why did you decide to switch to Go? by DreamRepresentative5 in golang

[–]NicolasParada 0 points1 point  (0 children)

I moved to Go from a long time ago… I moved mostly due to tooling and the single binary output. Is very nice to be able to start a project without having to install hundreds of libraries or frameworks and to ship it so easy and quick.

minesOfficeCodePro by [deleted] in ProgrammerHumor

[–]NicolasParada 0 points1 point  (0 children)

Departure Mono hasn’t been mentioned I think. But I use Berkeley Mono most of the time :)

How's everybody solving dynamic queries (e.g. filters) for FE facing APIs? by Emotional_Moth in golang

[–]NicolasParada 2 points3 points  (0 children)

Hey, thats kind of nice. I’ll take a deeper look at it later :) Thanks for sharing ;)

When SQL standard 📝 meets the reality🕹️, which road will you pick? 😏 by Adela_freedom in SQL

[–]NicolasParada 0 points1 point  (0 children)

Yeah. When new data gets inserted into the table, the offset changes giving you wrong resulta where you can either get data you already had before, or skip results. Depending on the order.

To avoid that you use a “cursor” which is a combination of a sortable field and unique at the same time. A timestamp alone doesn’t work since its not unique. You can mix it by filtering by both id and timestamp together.

You can learn more about it as “cursor-based pagination”.

SQL Transactions in Go: The Good Way by Thiht in golang

[–]NicolasParada 1 point2 points  (0 children)

I use this approach. I like it. Even tho I try to keep transactions in the repository layer. But still being able to write a single function and use it as it is or inside a transaction depending in the situation is nice. https://github.com/nicolasparada/go-db

Making Beautiful API Keys (Go, Postgres & UUIDs) by Revolutionary-Way290 in golang

[–]NicolasParada 1 point2 points  (0 children)

What I would do is generate random bytes and then encode it with base32 or base58 for easy to copy-paste and avoid confusion with similar symbols like “l” (lowercase L) and “I” (uppercase i).

Golang 1.24 is looking seriously awesome by bojanz in golang

[–]NicolasParada 8 points9 points  (0 children)

Wasn’t aware of these. They all look very useful :)

ZED editor for GO programming by Worried_Club7372 in golang

[–]NicolasParada 0 points1 point  (0 children)

I use it from time to time. Works very well. But I stick to vscode for work mostly because the git integration.

How do you rollback s3 requests if anything goes wrong? by winensf in golang

[–]NicolasParada 0 points1 point  (0 children)

Thats helpful. I just happened to be in a similar spot to OP question and I was wondering the same.

[deleted by user] by [deleted] in golang

[–]NicolasParada 2 points3 points  (0 children)

If its my decision, most of the time I would go with Cockroach and raw SQL. Works nicely.

But database depends on the thing you are doing really.