r/golang

▲ 7 r/golang

Help me with these topics!!

I'm currently learning golang from Learn Go with Tests and I am almost done with it but still I'm not getting confidence in Context, Reading Files, Templating and Generics. Like it really makes me wonder about the way I'm learning it. Can u people suggest a site or a channel from which I can learn these topics easily.

reddit.com
u/eethfxc234____---add — 6 hours ago
▲ 0 r/golang

What is a good way to test list of variables to see if any are equal to a specific value?

I have a function that loops through a CSV file looking for specific field names and captured the index of the field for later data collection.

Unfortunately, the organization (not mine) that creates the csv file is prone to randomly add field or move the data to a different column, but the column names are consistent.

To help detect if they changed a field name or omitted it altogether, what I want to do is set the field index to -1 and then use something like Python's "any()" function to say if any of (list of variables) = -1 after parsing the header row, then log the error and quit :) .

what would be a good way to implement this in Go?

var ( 
     firstIndex int = -1
     secondIndex int = -1
)

for {} // loop checks all of the headers and sets index to the index value.

//psuedo code
check the value of each index variable. if any equal negative one, return error. 

I hope that this makes sense. My thought is that I could put the indexes into a map , slice, struct, etc to make looping easier. but I'm still pretty new to Go. And no, I haven't asked AI yet, but that is a good idea!

Ideas?

reddit.com
u/xfinitystones — 12 hours ago
▲ 25 r/golang+4 crossposts

Open Source, local AWS deployments - looking for feedback

Hey! I've been working for a very early stage startup called Mulga. We've been continuously working on our flagship product, Spinifex, which recreates core AWS services such as EC2, EBS and S3, locally (and even air-gapped if you want/need!).

Have a poke around our GitHub: https://github.com/mulgadc/spinifex

Feedback/criticism welcome!

u/LegitimateWolf6611 — 22 hours ago
▲ 21 r/golang

The SAST scan is the slowest thing in our pipeline by a mile and people just skip it now.

I do not know how other teams put up with this. Our security scan runs on every PR and re-reads the whole repo each time, it is always the slowest step by a mile, slower than the build and the tests put together. During an outage last month it sat on a one line fix long enough that a lead just force merged past it and I did not blame him.

And now that is normal. People skip the scan whenever they are in a rush, which is most of the time then it still shows green on the dashboard so on paper nothing is wrong. A gate everyone routes around is not really a gate, it just looks like one in the audit.

So I am trying to work out how you make it fast enough that skipping it stops being the obvious move. Incremental scans that only look at what changed. Something in the editor you see it while you type instead of waiting on the pipeline. Both maybe. What is working for you, and did you give up coverage to get the speed.

reddit.com
u/Lance_Saul_85 — 1 day ago
▲ 61 r/golang

Remote Taskfiles are now generally available!

REMOTE TASKFILES ARE GENERALLY AVAILABLE!!

After 3 years being an experimental feature, this is now enabled by default.

You can now run and import Taskfile from a remote location, like a remote Git repository.

taskfile.dev
u/andrey-nering — 1 day ago
▲ 0 r/golang

Is there an expression form to "upcast" a value of concrete type to an interface type?

I am noodling on my own hobby programming language similar to Go in some respects. One aspect my language shares with Go is that there is no subtyping but types are assignable to interface types.

Now I'm trying to work out the syntax for that assignability. In Go, I know you can assign a concrete type to an interface type using a variable declaration:

type Concrete struct {
  n int64
}

type Abstract interface{}

func main() {
  var x Abstract = Concrete{1} // <--
}

This works, but requires you to write a statement and be in a position where you can do so. Is there a corresponding expression form that accomplishes the same thing? As far as I can tell, the answer is no. Type assertions are only used for "casting" the other way, from an interface to a concrete type.

(In Go, arguments will be converted to the expected parameter in calls as well. That won't work well in my language since my language has overloading and that would heavily complicate overload resolution.)

reddit.com
u/munificent — 1 day ago
▲ 36 r/golang

Small Projects

This is the weekly thread for Small Projects.

The point of this thread is to have looser posting standards than the main board. As such, projects are pretty much only removed from here by the mods for being completely unrelated to Go. However, Reddit often labels posts full of links as being spam, even when they are perfectly sensible things like links to projects, godocs, and an example. r/golang mods are not the ones removing things from this thread and we will allow them as we see the removals.

Please also avoid posts like "why", "we've got a dozen of those", "that looks like AI slop", etc. This the place to put any project people feel like sharing without worrying about those criteria.

reddit.com
u/AutoModerator — 2 days ago
▲ 17 r/golang

oida - in process telemetry

I was writing a status page for phpscript, and kept upgrading it to the point I wanted to make it reusable between projects, as a quick live view. It was too nice to keep it hidden away under internals.

If you want to start with observability without pulling in opentelemetry or run additional services, oida lets you collect traces and view them, monitor memory usage, GC.

The initial implementation was meant to be closer to lighthttp/nginx status page where you can see requests in flight. I spent a lot of time polishing the front end, migrated to templ, and spent too much time on timeline visualizations (discarded several other attempts - voronoi, voxels, circles, lines, and timeline). It outgrew the basic use case.

I used claude to assist with migrating/updating/extracting the package from phpscript, usage docs. I did heavy manual QA as well, polishing it for usage. Would love some adoption by solo devs or small teams, people doing local development who maybe don't have telemetry at all. If you're missing something, shout out!

Edit: here are the screenshots, to save you a click.

github.com
u/titpetric — 2 days ago
▲ 0 r/golang

How do i turn my CLI program into Docker like service

So i have a CLI app built with go , really simple one actually I start the program I get menu option I enter input something happens .
But i want to change it to make it like a tool that runs in background and i enter toolname to access its functionality through terminal anytime . I have never made something like this so i though I could ask community for help

reddit.com
u/Square-Butterfly8447 — 2 days ago
▲ 8 r/golang

Stackdome: An opensource Go control plane for deploying application stacks to Kubernetes

I have been working on Stackdome, a self hosted application delivery platform. (Currently in Alpha). Think of it like a railway equivalent that you can run on your own infra or locally.

Repository: https://github.com/Stackdome/Stackdome

With Stackdome, you can deploy an application from GitHub, connect multiple services visually, add a managed database, create preview environments.
The go control-plane packages the whole application as a "Stack" (A new custom resource created by stackdome) and deploys it on k8s. Each deployment happens as a release and can be rolled back.

Basically, the idea is to package the tooling in the CNCF/cloud-native ecosystem into an opinionated platform, so that developers can get a well engineered platform without learning Kubernetes YAMLology or a dozen other projects from the CNCF landscape.

Architecture:
Stackdome has a hub and spoke architecture. Hub is the control-plane and spokes are the k8s clusters (Which run our custom controller which lifecycles our CRs). The hub can place the workloads in clusters. (Currently we support only one cluster, but the architecture is supports multicluster).

- The hub exposes a REST API, stores application and release state in PostgreSQL.
- Establishes controller runtime watches for each of the registered cluster using a cluster manager.
- We also use client-go rate-limted queues in the hub to "reconcile" the desired resources from the backend on to the cluster. See: https://github.com/Stackdome/Stackdome/blob/main/pkg/worker/types.go

You can use this command to setup Stackdome on a bare linux server:

`curl -fsSL https://get.stackdome.com/install.sh | sudo sh`

One cool thing about the installer is that it uses stackdome constructs to install itself.
So we dogfood our own constructs to run stackdome. :))). [See it here]

Or you can use our cloud playground at cloud.stackdome.com

Steps to run it locally: https://github.com/Stackdome/Stackdome/blob/main/DEVELOPMENT.md

u/ashishmax31 — 2 days ago
▲ 6 r/golang

From Frontend js -> Go

Hi!

I was working in the Web development 11 years aprox

Most time i was working like frontend developer (i worked with jquery, AngularJS, Angular, React…) also i was working too in some project like fullstack (with php and node.js in back side)

I discovered golang and i was following this years and i love it!

What path do you recommend to me for make the transition from frontend js world to golang?

What kind of side projects recommend to me for create a valid portfolio for find work with golang?

Thanks!

reddit.com
u/h3v0rr1ll0 — 3 days ago
▲ 0 r/golang

Hive: embeddable leaderless distributed cache, no sidecar/infra, just a Go import

I've been working on this pet project for a few months now, is a distributed cache you import directly into a Go service instead of running as a separate process or sidecar. Currently using it on a couple of my other projects.

A few design notes if you're into the internals:

  • Consistent hashing for data distribution, rebalancing, replication, and even weighted keyspace by the node's memory limit.
  • Gossip protocol for discovery and cluster state syncronization.
  • Minimal dependencies, just msgpack for serialization (storage/transport).
  • Self healing. Gossip failure detection using incarnation numbers seeded from wall time, so a restarted node can rejoin without manual intervention. Last-write-wins conflict resolution when a partition heals.

It's deliberately not trying to be Redis, no persistence (outside replication rebalancing), eventually consistent. It's aimed at session caches, rate limiters, presence tracking, leaderboards, job queues, etc. things where staleness or a restart-loss is fine and you'd rather not stand up a separate service.

Repo: https://github.com/EmilioRosiles/hive

Would love feedback on the API and config defaults, and bug reports/feature requests are welcome.

u/Used-Alarm-8949 — 3 days ago
▲ 17 r/golang+5 crossposts

I built Network Doctor, an open-source terminal app that shows where your connection breaks

When a host is unreachable, troubleshooting usually means running ping, dig, curl, and traceroute, and others, then piecing their outputs together.

So I built Network Doctor to solve that issue!

It checks the connection in stages, and explains where the chain failed in plain English.

Check it out: https://github.com/heymaikol/network-doctor

u/mplaczek99 — 4 days ago
▲ 17 r/golang+2 crossposts

dskDitto v 0.6.1 release

Hey all. I recently released https://github.com/jdefrancesco/dskDitto v0.6.1 which now supports reflinks for duplication if your FS supports it. You can grab and install the @latest as well as grab the GUI by following the instructions in the READMe.md

u/jdefr — 3 days ago
▲ 77 r/golang+1 crossposts

Java → Go Career Transition

I’m primarily a Java developer. In my previous company, I worked almost exclusively with Java, and I have a good command of DSA in Java as well.
I recently switched to another company where I’m working with both Java and Go. From what I’ve seen so far, the Go team is working on some really interesting problems, especially around system scalability and performance, compared to the Java side.
Because of this, I’m considering moving completely toward Go for my future career. My main question is: Should I start doing DSA in Go as well, or should I continue practicing DSA in Java?
If I’m planning to switch to Go-focused roles in the future, would knowing DSA in Go give me any advantage during interviews, or is it better to stick with Java since the concepts are what matter?
Honestly, I’m also getting a bit tired of writing the same kind of Java code and would like to explore Go more seriously.
Would appreciate advice from people who have made a similar transition from Java to Go.

Btw i have just joined the new company like 1 month ago.

reddit.com
u/GreateMind — 5 days ago