/r/golang
Ask questions and post articles about the Go programming language and related tools, events etc.
Post is not in keeping with an inclusive and friendly technical atmosphere.
Remember that people have varying communication styles and that not everyone is using their native language. (Meaning and tone can be lost in translation.)
Productive communication requires effort. Think about how your words will be interpreted. Remember that sometimes it is best to refrain entirely from commenting.
In particular, respect differences of opinion.
Interpret the arguments of others in good faith, do not seek to disagree. When we do disagree, try to understand why.
Avoid derailing: stay on topic; if you want to talk about something else, start a new conversation. Avoid unconstructive criticism: don't merely decry the current state of affairs; offer—or at least solicit—suggestions as to how things may be improved. Avoid snarking (pithy, unproductive, sniping comments) Avoid discussing potentially offensive or sensitive issues; this all too often leads to unnecessary conflict. Avoid microaggressions
What you say and do matters. Take responsibility for your words and actions, including their consequences, whether intended or otherwise.
As a part of the Go community, this subreddit and those who post on it should follow the tenets laid out in the Go Code of Conduct: https://golang.org/conduct
Treat everyone with respect and kindness. Be thoughtful in how you communicate. Don’t be destructive or inflammatory.
Posts must be of interest to Go developers and related to the Go language.
This includes: - Articles about the language itself - Announcements & articles about open source Go libraries or applications - Dev tools (open source or not) specifically targeted at Go developers
We ask that you not post about closed-source / paid software that is not specifically aimed at Go developers in particular (as opposed to all developers), even if it is written in Go.
Do not post links to or instructions on how to get pirated copies of copyrighted material.
We have a monthly "Who's Hiring?" post that will stay pinned to the top of the subreddit. To avoid too much noise from companies, please post job openings there. Please keep in mind, this is for 1st party postings only. No 3rd party recruiters.
No GPT or other AI-generated content is allowed as posts, post targets, or comments. This is only for the content itself; posts about GPT or AI related to Go are fine.
As GPT content is difficult to distinguish from merely low-quality content, low-quality content may be removed too. This includes but is not limited to listicles and "Go tutorials" that have no human voice and add nothing of their own.
/r/golang
Do you use a the party package which makes building http clients more convenient?
Which one do you use, and why?
Hi, I want to learn golang and start using it daily. I am not new to programming since I started my career in 2013.
I am looking online for resources and I would like to know from more experienced people, where can I found good quality courses/tutorials.
I enjoy courses/tutorials where you actually build something, like an ecommerce, a blog or anything else from scratch, since they are the best way (in my opinion) to learn something.
I found this for the moment:
https://gowebexamples.com/
my repo public opensource
Good day team. I have a work app that uses js front and back, and we want to migrate everything to go. I’ve already sorted most of it, almost completely with standard library packages. But there is some pdf generation in the backend that uses puppeteer. We’ve done a small amount of research and were wondering if anyone had some recommendations (standard lib or not) or repos that we could look over.
Im curious to hear what packages, features, and particularly useful functions/methods you have found in go and life was never the same after.
What stlib packages are the most useful for what you do?
Hi, everyone! 👋
I'm excited to introduce Swama, a CLI tool designed to make working with Swagger/OpenAPI definitions easier and faster. If you’re frequently working with APIs and want to interact with Swagger files directly from the command line, Swama might be just what you need!
curl
or fetch
commands for easy testing.You can download pre-built binaries for Linux, macOS, and Windows from the releases page.
Alternatively, build it from source:
git clone
cd swama
go build -o swamahttps://github.com/idsulik/swama
swama endpoints list --file api_spec.yaml
swama mock-server run --port 8080
swama endpoints convert --endpoint /users --method GET --type curl
Check it out here: Swama GitHub Repo
I’d love to hear your thoughts! Feel free to report issues, suggest features, or submit PRs on GitHub.
If you find it useful, please consider giving the project a ⭐️ on GitHub – it’s a huge help and really appreciated!
I've been using Go for a while now, but only lately have had to deal with manipulating yaml files (hell).
Right now there's
For the most part, https://github.com/go-yaml/yaml is the main one that most use, but I can confidently say that it's very broken for anything other than marshaling or unmarshaling into and out of standard go structs (and even that is buggy).
There's currently nearly 300 issues open, and over 100 PR's open with the last commit being 2 years ago. I believe the maintainer is 1 person who is busy with other things (all the power to them, they don't owe anyone anything). For all intents and purposes it's deprecated.
https://github.com/go-yaml/yaml has its own set of issues. Most tooling doesn't use it as the base library, and I believe it's also a little buggy though I can't really comment since I haven't used it as much. That said, it's also maintained by one person.
Due to the importance of yaml parsing these days, is there any centralized movement towards providing something like the json library (ie, maintained by the core language creators?) or is there an alternative that people are looking at?
I'm working on a REPL (Read-Eval-Print Loop) program in Go and want to add a feature for real-time command suggestions, similar to search engine suggestions. I understand that I need one goroutine to accept user input and another to generate suggestions based on that input. However, I'm unsure about how to read user input continuously while also updating the suggestions in real-time.
Your Answers are Appreciated
Note: I am Making this to Learn So no External Libraries I just want to Learn ...
I'd like to read some of them :)
Simple and easy lightweight API Gateway . It comes with integrated features, such as:
Hi everyone!
Using my newly gained basic understanding of SMTP, I have created a TUI application using Rivo's Tview library that lets you send emails using a TUI-Application:
Since SMTP is used for sending emails, I am current looking for a protocol or API that would allow me to view my inbox after signing-into my Gmail account from this very TUI-Application.
I'd love for you to check out the repository and share your feedback! Any suggestions, ideas, or improvements would be greatly appreciated.
By playing with TinyGo (Golang embedded) I came to drones/UAVs.
Just found:
Before starting (hopefully) a new payed project I would like to do more Go :) Therefor I'm looking for a really, really cheap drone which I can program using Golang. Camera and video would be nice, but to be honest I think the thing will fly against the wall of my house a few times and probably be broken before I would even begin to use the video/camera function. I would like to fly 1-3 drones (depending on the price) in formation and have colourful LEDs flash / light up instead of fireworks on new year's eve. Needs to be really cheap, because I need to save up some money to have to pay for medics/treatment (is actually not common in Germany) to shorten a waiting time of >8 months to <1 week. I am open to everything.
EDIT: First Url wrongly copied. Striketrough seems not to work. It was: https://github.com/drone/drone-go
I received an enquiry for a possible future Golang project and was explicitly referred to TLA+. TLA+ was created by Leslie Lamport, a well known LaTeX dev. I found this: https://lamport.azurewebsites.net/tla/tla.html I also found "Finding Goroutine Bugs with TLA+": https://www.hillelwayne.com/post/tla-golang/ Is TLA+ a topic related to Golang? I'm using Golang since 2016 and did >10 "bigger" projects but so far I've had nothing to do with it. Would appreciate any experience and recommendations you would like to share.
I've been working in a team that uses Go for its microservices for about 4 months now. I have zero prior experience with Go, my background is primarily Java. One thing that I find difficult to wrap my head around is the lack of a clear pattern in the way that these services are written. I've been accustomed to Spring Boot's controller-service-repository pattern which i like very much, its easy to grasp and the separation of concerns between the layers is well-defined.
In our codebase however, I find it difficult to reason where a piece of code should reside especially when the project structure can vary a lot from service to service. In some services, there are random helper and util functions that encapsulate business logic, and I find myself spending too much effort thinking where I should be writing my code. Then in some other services, i see request handlers that do everything from unmarshalling the request body, validation to calling the DB that results in giant functions.
Maybe its just my inexperience as a SWE, but is it normal for Go services to be written without following any pattern? If not, what useful patterns do you recommend?
Hi,
Do you know a Golang equivalent of the Javascript listr2 library?
My goal is to create a cli tool with the same rendering as demonstrated in the screencast on https://listr2.kilic.dev
Listr2:
Create beautiful CLI interfaces via easy and logical-to-implement task lists that feel alive and interactive.
Best regards,
Stéphane
Not long ago, I published an experimental Go tool for effortlessly generating mock HTTP APIs. You can check it out on GitHub: https://github.com/trco/wannabe.
My next "big plan" is to support dynamic HTTP response generation using AI, with a focus on date ranges. In simple terms, this means you could record an HTTP response for a request with a specific date range, and then use that response as a template for AI-generated responses across arbitrary date ranges.
I have a few questions to see what do you think of such plans:
So recently I came across this side called codecrafters and tried out building a http server. I think it turned out to be pretty good. I would like you guys to look through it and suggest me some enhancements and correction if i have done something wrong.
Go enforce module being versioned using the semantic versioning model, doing so manually can be tedious and prone to error.
Automating this task was for me a good first open-source Go project: Go Semver Release, a program built to automate the versioning of your Git repositories using their formatted commit history.
How is it different from other such tools ?
Feedbacks are more than welcome !
Probably something like this already exists, but I wanted a simple and secure way to share snippers between machines, so I created https://notepad.moe! All notes are securely encrypted with AES, and can only be accessed if you know the URL. Feedback welcome! This is the first time I've really done anything with encryption, so I expect it's completely broken somehow.
I've been doing Go for several years now, but before that I worked with Java for about 20 years. I've written up how my approach to data structure design changed as I got more comfortable with Go.
What was particularly interesting to me is that Go pushed me towards design patterns that I already considered best practices when working with Java. However, it wasn't till I switched languages that I was able to shift my habits.
Curious if others have had similar experiences, and especially how the experience was for people coming from other languages (python, rust, C or C++).
This post will be stickied at the top of until the last week of November (more or less).
Please adhere to the following rules when posting:
Rules for individuals:
Rules for employers:
COMPANY: [Company name; ideally link to your company's website or careers page.]
TYPE: [Full time, part time, internship, contract, etc.]
DESCRIPTION: [What does your team/company do, and what are you using Go for? How much experience are you seeking and what seniority levels are you hiring for? The more details the better.]
LOCATION: [Where are your office or offices located? If your workplace language isn't English-speaking, please specify it.]
ESTIMATED COMPENSATION: [Please attempt to provide at least a rough expectation of wages/salary.If you can't state a number for compensation, omit this field. Do not just say "competitive". Everyone says their compensation is "competitive".If you are listing several positions in the "Description" field above, then feel free to include this information inline above, and put "See above" in this field.If compensation is expected to be offset by other benefits, then please include that information here as well.]
REMOTE: [Do you offer the option of working remotely? If so, do you require employees to live in certain areas or time zones?]
VISA: [Does your company sponsor visas?]
CONTACT: [How can someone get in touch with you?]
I'm working on a library to make interaction between Go and Python very easy: https://github.com/cpunion/go-python
Anyone interested?
What is the best way to scan null DB fields into a struct? How do I deal with null fields in a database? My options are:
Which of these is more performant? Which one do you use? Which one would you recommend? Are there other ways? Bad experiences with pointers? Any blog posts regarding this? I asked GPT but it simply gave me simple pros and cons and not much more than that.
NullString seems like a no brainer, but NOT NULL is also quite attractive. I use postgresql. Does NOT NULL need more space on disk? Does it make creating new rows slower? Any problems doing it on scale? It's a very attractive solution! It's the one I currently use for my poc. GPT says it actually is more performant than using nullable fields because the null check is skipped.
Another question would be, should I scan into a struct which is different from that which I send off at the api endpoint?
Its has been a quite a few releases since I last posted about Zog (https://github.com/Oudwins/zog) v0.9.0.
I case you are not familiar, Zog is a Zod inspired schema validation library for go. Example usage looks like this:
type User struct {
Name string
Password string
}
var userSchema = z.Struct(z.Schema{
"name": z.String().Min(3, z.Message("Name too short")).Required(),
"password": z.String().ContainsSpecial().ContainsUpper().Required(),
})
// in a handler somewhere:
var user User
errs := userSchema.Parse(map[string]string{"name": "Zog", "password": "nop"}, &user)
We have added a bunch of new bug fixes and small tweaks. Notable changes:
Support for uuid validation and regexes: This has been missing for a while and I was very happy to see @amaro0 contribute the validations.
Better error printing for debugging: Zog already has some of the best errors of any validation library out there but there was one small thing missing. Printing the errors easily in a nice format for debugging. I had to dive deep into the stdlib to figure out the issue but I'm happy to say that its working perfectly.
// example printing the result of parsing a primitive type:
fmt.Println(errs) // [ZogError{Code: coerce, Params: map[], Type: number, Value: not_empty, Message: number is invalid, Error: failed to coerce string int: strconv.Atoi: parsing "not_empty": invalid syntax}]
90%+ code coverage: This was necessary to apply for the awesome-go project but also just a sign that Zog is ready to be used in production (in fact we have quite a few people actively using it in production today!)
edit: RIP I forgot to add "release" to the title. edit2: forgot github link