Golang

2450 readers
1 users here now

This is a community dedicated to the go programming language.

Useful Links:

Rules:

founded 2 years ago
MODERATORS
1
2
3
4
5
6
 
 

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!

7
 
 

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

8
9
1
O(no) You Didn’t (mrshiny608.github.io)
submitted 1 month ago by tyler to c/golang
10
 
 

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

11
 
 

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:

12
 
 

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.

13
 
 

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).

14
15
11
Golang On The PS2 (hackaday.com)
submitted 2 months ago by [email protected] to c/golang
16
 
 

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

17
17
TIL pprof is a thing (lemmy.dbzer0.com)
submitted 2 months ago by [email protected] to c/golang
 
 

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.

18
19
20
 
 

It appears to pass all tests, but I'm not sure if my test writing skills are necessarily that great, I semi-followed the learn go with tests eBook. I appreciate any feedback, and if this isn't an appropriate post for this community just let me know and I'll remove.

Thanks!!

*** Update *** Updated the repository to be a bit more discriptive of what the library is for and added in a small example project of it in action.

21
 
 

Applying Hexagonal Architecture to a Mid-Size Go Backend

https://sams96.github.io/go-project-layout/

I put this post together to organise some thoughts I've been having about software architecture when it comes to Go web backends.

#golang @golang

22
7
submitted 3 months ago by [email protected] to c/golang
 
 

https://github.com/theHamdiz/it

A collection of helpful error handling, performance measuring, execution retrial, benchmarking & other useful patterns for golang under one package.

Because we kinda need this shit daily and we know it!

I don’t think anything i post here would do the project justice outside of just copying the read me.

23
24
 
 

cross-posted from: https://lemmy.ml/post/25903183

I wrote a CLI tool that generates basic scaffolding for all sorts of coding projects, from Zig applications to NPM packages.

Feel free to ask questions or contribute!

25
view more: next ›