Golang

2696 readers
2 users here now

This is a community dedicated to the go programming language.

Useful Links:

Rules:

founded 3 years ago
MODERATORS
101
102
103
 
 

Cross-posted from "How could I allow users to schedule sending emails at a specific interval?" by @lena@gregtech.eu in !learn_programming@programming.dev


Basically, I'm trying to figure out how I could allow a user to send a schedule in the cron syntax to some API, store it into the database and then send an email to them at that interval. The code is at gragorther/epigo. I'd use go-mail to send the mails.

I found stuff like River or Asynq to schedule tasks, but that is quite complex and I have absolutely no idea what the best way to implement it would be, so help with that is appreciated <3

104
105
106
107
108
109
 
 

I'm working on a rather fresh project and that makes me question stuff I take for granted in existing projects. One of those things is how we access context. In existing projects, we use functions like "foobarFromContext(ctx)" that grab foobar from context for us. Writing to context usually happens in middleware.

When I was tinkering with deno + hono, context was frequently accessed directly instead of get funcs and it felt way more volatile? and I liked that.

I try to look at context as a "dynamic constants container", so stuff that is probably permanent for the lifespan of the context, e.g. the authorized user that made the call. So keep writing to context in middlewares is less of a problem for me, but get-funcs that have to be injected to each and every service and mocked in tests for a simple "ctx.Value("userName") sometimes seems so overengineered and makes ctx feel like some distant, transcendend thing.

What's your way?

110
111
112
 
 

Hi Gophers! I recently launched and open sourced Cloud Snitch, a dashboard and firewall for AWS activity. The backend is 100% Golang! /r/golang liked it and I hope you will too!

113
 
 

The Go team is working on a new garbage collector called Green Tea.

114
115
116
 
 

Uma nova skill, ainda tem muito chão pra percorrer e caminhos a trilhar, mas hoje conquistei uma nova badge para minha coleção. Primeiros passos em @golang mais uma ferramenta para meu #ToolBelt

117
 
 

I had some free time this weekend and I've spent some of it trying to learn Go since mlmym seems to be unmaintained and I'd like to try to fix some issues in it. I ran into a stumbling block that took a while to solve and which I had trouble finding relevant search results for. I've got it solved now, but felt like writing this up in case it helps anyone else out.

When running most go commands I tried (e.g. go mod init example/hello or go run hello.go or even something as seemingly innocuous as go doc cmd/compile when a go.mod file exists) the command would hang for a rather long time. In most cases, that was about 20~30 seconds, but in one case -- trying to get it to output the docs about the compile tool -- it took 1 minute and 15 seconds! This was on a relatively fresh Linux Mint install on old, but fairly decent hardware using golang-1.23 (installed from apt).

After the long wait, it would print out go: RLock go.mod: no locks available -- and might or might not do anything else depending on the command. (I did get documentation out after the 1min+ wait, for example.)

Now, there's no good reason I could think of why printing out some documentation or running Hello World should take that long, so I tried looking at what was going on with strace --relative-timestamps go run hello.go > trace.txt 2>&1 and found this in the output file:

0.000045 flock(3, LOCK_SH)         = -1 ENOLCK (No locks available)
25.059805 clock_gettime(CLOCK_MONOTONIC, {tv_sec=3691, tv_nsec=443533733}) = 0

It was hanging on flock for 25 seconds (before calling clock_gettime).

The directory I was running in was from an NFS mount which was using NFSv3 unintentionally. File locking does not work on NFSv3 out of the box. In my case, changing the configuration to allow it to use NFSv4 was the fix I needed. After making the change a clean Hello World build takes ~5 seconds -- and a fraction of a second with cache.

After solving it, I've found out that there are some issues related to this open already (with a different error message -- cmd/go: "RLock …: Function not implemented") and a reply on an old StackOverflow about a similiar issue from one of the developers encouraging people to file a new issue if they can't find a workaround (like I did). For future reference, those links are:

118
 
 

Putz travei nos estudos de @golang simplesmente não está funcionando, mas tb não dá erro ahahah responde qq endpoint da minha API com o mesmo, mesmo que seja um endpoint que não existe ele retorna sempre o mesmo valor, no qual deveria, já que não existe, ser um 404. Não sei o que estou fazendo de errado, mas tá foda hahahah Quebrando a cabeça aqui.

119
 
 

hi there,

Star-TeX v0.7.1 is out:

After a (very) long hiatus, development of Star-TeX has resumed. Star-TeX is a pure-Go TeX engine, built upon/with modernc.org/knuth.

v0.7.1 brings pure-Go TeX → PDF generation.

Here are examples of generated PDFs:

PDF generation is still a bit shaky (see #24), but it's coming from the external PDF package we are using rather than a Star-TeX defect per se.

We'll try to fix that in the next version. Now we'll work on bringing LaTeX support to the engine (working directly on modernc.org/knuth).

120
121
122
 
 

Go 1.25 simplifies the language spec by removing the notion of core types

123
 
 

Found myself trying to debug an issue with memory not being garbage collected in a program. It turns out go comes with a tool that shows you the different memory allocations and resource hogs between different goroutines. Super useful so far from what I've found on some basic debugging, but still trying to understand how the flamegraph, the visualizations when writing to a png, and some other utilities in there work.

Overall was happy to learn that there was included tooling for that purpose within go itself.

124
125
view more: ‹ prev next ›