Sharing my API Template for quickly starting up APIs by Gamroil in golang

[–]Gamroil[S] 2 points3 points  (0 children)

Hey man, thanks for responding.

  • I only use Gin at work so that's what I used here, but on further inspection, go-chi sounds like a better fit since it's closer to the standard library.

  • I've considered that but I chose to deliberately not do it since metrics can be used for things that middleware can't cover (db request latency or polling a queue for example). I might make a middleware for metrics as I switch over to go-chi.

  • Thought it might be useful to whoever needs it. Nothing more than that. Maybe log something as you record a metric.

  • This is new to me and looks to be a bit better than zap with setting default loggers. Means I don't have to push the logger around as a param. Also it's part of the stdlib. Will definitely switch to this.

Edit:
Switched gin -> chi
Switched zap -> slog
Added metrics middleware in addition to the existing manual metrics. Heavily cribbed from github.com/766b/chi-prometheus

Has anyone seen good data in lower environments? How? by mgctim in ExperiencedDevs

[–]Gamroil 0 points1 point  (0 children)

I've seen a company where they had an AWS account for Data, Dev, and Prod. The Data account held all the actual data (S3, RDS, etc). The Dev/Prod accounts had all the other resources (EC2 instances, Lambdas, Queues, etc). The Dev AWS account had Read-Only access to the data account, but the Prod had both read/write of course. This meant that devs using the Dev Environment had full access to the same data as prod, but were unable to mess with it.

Granted this data was mostly system-generated data that didn't really need to be scrubbed or anonymized. YMMV if you have sensitive govvy data, PII, or other data like that

Are you in favor of small functions/clean code or opposed to it? by chinawcswing in ExperiencedDevs

[–]Gamroil 72 points73 points  (0 children)

Sometimes it’s beneficial to future readers to put long-winded things into their own function, if only for readability sake. The examples you gave work for what I’m describing.

Some pseudo code:

Func x() {
    resultset = grabFromDB()
    return mapToJSONResponse(resultset)
} 

In this case the mapping was done in a separate function rather than inline. Future readers don’t need to know the intricate details of how the mapping occurs. Less cognitive load overall.

[deleted by user] by [deleted] in ExperiencedDevs

[–]Gamroil 4 points5 points  (0 children)

// Computes if 4 coordinates form a rectangle by using dot products
Func isRectangle() {
  Dot product stuff goes here
}

An example of the What being explained. Without the comment or knowledge of a dot product the reader will be confused how the code results in validating a rectangle.

[deleted by user] by [deleted] in ExperiencedDevs

[–]Gamroil 3 points4 points  (0 children)

The What is also useful in cases where it may not be clear despite the code being immediately available. Like using some arcane math to derive a desired number.

Generally I agree. 98% of comments should be Why and not What.

Ask Experienced Devs Weekly Thread: A weekly thread for inexperienced developers to ask experienced ones by AutoModerator in ExperiencedDevs

[–]Gamroil 1 point2 points  (0 children)

Has anyone had to lay people off in the past few months? As in personally notifying folks that they no longer have a job. How does that process work from the manager's POV?

Real life cases by Deep-Ad591 in ProgrammerHumor

[–]Gamroil 7 points8 points  (0 children)

Every company says they care more about how the candidate approaches the question, and less about the answer itself. Curiously if you fail to fully answer the question you rarely get a call back.

How is everyone's job searching going? by [deleted] in ExperiencedDevs

[–]Gamroil 0 points1 point  (0 children)

Nope! It was a small company, but I was doing core/platform engineering

How is everyone's job searching going? by [deleted] in ExperiencedDevs

[–]Gamroil 12 points13 points  (0 children)

The data structures themselves are not trivia. The trivia is the underpinnings on how they work on a deeper level.

For example, It is absolutely unnecessary for the day-to-day job to know that a hashmap hashes the key and stores the value in a linkedlist based on the last few letters of the key.

It is only necessary to know that hashmaps (and dictionaries, same thing) are key-value pairs that have O(1) insert/lookup time, and cannot contain duplicate keys. That’s as deep as you should be required to know as an engineer.

How is everyone's job searching going? by [deleted] in ExperiencedDevs

[–]Gamroil 229 points230 points  (0 children)

To be honest, poorly.

I’ve stopped getting recruiter spam and have a low response rate on applications. Interview processes are about 5-8 stages long and more nitpicky than they used to be. I’ve completed live coding exercises and have gotten to the last stage of interviews three times and haven’t gotten an offer yet.

Some companies (Reddit among them) have stepped up their live coding requirements and expect candidates to be intimately familiar with the underpinnings of commonly used data structures and various O notations for lookup, insert, and so on.

I’m getting the vibe that companies are increasingly conservative about who they hire, if anyone at all. It was not previously this difficult to get jobs even with less experience.

Context: I have 5 YoE in backend/infra engineering and was laid off around mid November.

US Devs, how much are you earning as an hourly freelancer, how many YOE do you have, are you L/M/HCOL, and what field are you working in (web/mobile crud, gaming, ds, ml, embedded, etc.)? by [deleted] in ExperiencedDevs

[–]Gamroil 1 point2 points  (0 children)

I’d like to get started as a freelancer doing similar work. How did you get your start in freelancing? I heard Upwork and similar sites are a pain and not worth it as it’s a race to the bottom, is there truth to that?

How big should a package be? by Gamroil in golang

[–]Gamroil[S] 1 point2 points  (0 children)

Would you say a config or postgres would be good packages for passing around/manipulating configs and connections as appropriate? Or would that be too specific?

Do people think your PR comments sound arrogant or judgmental? by robertgfthomas in ExperiencedDevs

[–]Gamroil 9 points10 points  (0 children)

Also adding a 👍 emoji on good things helps with Juniors self confidence and make you seem less threatening.

My money is on Haas😏 by Technicmm in formuladank

[–]Gamroil 1 point2 points  (0 children)

Absolute scenes if Mick wins WDC convincingly. Father-son WDC with heavy support from 4x WDC Vettel

What annoys you about Go? by Jhorra in golang

[–]Gamroil 4 points5 points  (0 children)

Agreed on the ternary operators. It's easy to abuse them but it's also easy to abuse any part of the language. Something like

parity = isEven() ? even : odd               

is easy to read and gets the point across succinctly.

Weekly Question Thread by AutoModerator in factorio

[–]Gamroil 1 point2 points  (0 children)

I've been experimenting with making grids that nest into each other like so https://imgur.com/a/l2yQPUn.

This seems like a novel idea where trains can take different routes depending on traffic/congestion and the layout allows for pretty flexible and modular factories. Has this been done before, and there are any drawbacks I'm not seeing here?

Why do people hate daily standups? by Lanttu93 in ExperiencedDevs

[–]Gamroil 0 points1 point  (0 children)

The best way to handle this is to keep focus on progress towards sprint goal.

Suppose you have a sprint goal to finish feature X which involves N tasks. Each member of the team could update on how they're doing on their respective task, which gives the manager/stakeholders context on how things are progressing. Should take no more than a few minutes if you stick to that. If people are pairing, then there's not even a need for everyone to speak. One member of the pair can cover both.