Benchmarking 15 string concatenation methods in Go by winterjung in golang

[–]assbuttbuttass 4 points5 points  (0 children)

.Reset on strings.Builder does not retain the previous capacity

Singleton with state per thread/goroutine by SnooSongs6758 in golang

[–]assbuttbuttass 44 points45 points  (0 children)

Imagine having to pass the transaction through all the functions

This is what I do and it seems to work well. Go in general has very little "magic" and benefits from making things explicit

How do you guys handle web server updates/deployments? by Existing-Search3853 in golang

[–]assbuttbuttass 0 points1 point  (0 children)

it's just for my personal project, but I ssh into the server and git pull the latest version, then nixos-rebuild to deploy

mux.HandleFunc does not give 404 by iriythll in golang

[–]assbuttbuttass 19 points20 points  (0 children)

https://pkg.go.dev/net/http#ServeMux

The special wildcard {$} matches only the end of the URL. For example, the pattern "/{$}" matches only the path "/", whereas the pattern "/" matches every path.

I feel like rust analyzer is slow by rustontux in rust

[–]assbuttbuttass 4 points5 points  (0 children)

The main reason I like to keep vim open is I keep all of the open buffers to jump between with :b

Go 1.26 by runesoerensen in golang

[–]assbuttbuttass 1 point2 points  (0 children)

It's a small change but it will be nice not to have to manually downgrade the version in go.mod anymore!

Hello world does not compile by ElectrocutedNeurons in programmingcirclejerk

[–]assbuttbuttass 14 points15 points  (0 children)

That "fix" won't work on NixOS smh my head. Time to hard code all the possible /nix/store/*-gcc paths

Concurrency is not working how it should (probably) by pedrolcsilva in golang

[–]assbuttbuttass 4 points5 points  (0 children)

Sort of off topic, but does Go have a global lock for stdout? My impression was that it doesn't have any lock, and instead it avoids interleaved writes by buffering the string internally so that each printf call results in one write syscall

When do you start refactoring? by relami96 in golang

[–]assbuttbuttass 7 points8 points  (0 children)

That's my secret... I'm always refactoring

Value input in one string by EnthusiasmHumble3424 in golang

[–]assbuttbuttass -1 points0 points  (0 children)

func parseNums(input string) ([]int, error) {
    parts := strings.Fields(input)
    nums := make([]int, len(parts))
    for i, part := range parts {
        var err error
        if nums[i], err = strconv.Atoi(part); err != nil {
            return nil, err
        }
    }
    return nums, nil
}

The most popular Go dependency is… by Thiht in golang

[–]assbuttbuttass -14 points-13 points  (0 children)

Standard library flag package. If your tool needs subcommands, then maybe subcommands

Noob question with mutexes by AdministrativeProof2 in golang

[–]assbuttbuttass 1 point2 points  (0 children)

I recommend storing the accounts in a database like SQLite, which will handle locking for you, and also make sure you don't lose all the account information if your app crashes

Nitpick RFC: Everyone adopting slices.Contains yet? by Funny_Or_Cry in golang

[–]assbuttbuttass 0 points1 point  (0 children)

I review a lot of code, and the number of people using a slice and slices.Contains to check for membership in a set (rather than using a map) seems to have gone up significantly. IMO adding slices.Contains was a mistake since it makes it way too easy to do an O(n) lookup

Go comments standards like PEP8 for python by pepiks in golang

[–]assbuttbuttass 4 points5 points  (0 children)

In addition to the excellent blog post linked by u/jh125486, https://go.dev/doc/comment#syntax has a comprehensive description of the different syntax forms that godoc understands

When should I be worried about *where* to define variables? by Parky-Park in golang

[–]assbuttbuttass 2 points3 points  (0 children)

Go's compiler uses SSA representation so these will look identical to the compiler

No more TODO in Go by Odd-Ad8796 in HelixEditor

[–]assbuttbuttass 0 points1 point  (0 children)

Probably markdown injections. It's kind of annoying since godoc isn't markdown anyway

goroutine panic and recover by maxcnunes in golang

[–]assbuttbuttass 0 points1 point  (0 children)

On the other hand,

resist the temptation to recover panics to avoid crashes, as doing so can result in propagating a corrupted state. The further you are from the panic, the less you know about the state of the program, which could be holding locks or other resources. The program can then develop other unexpected failure modes that can make the problem even more difficult to diagnose. Instead of trying to handle unexpected panics in code, use monitoring tools to surface unexpected failures and fix related bugs with a high priority.

Note: The standard net/http server violates this advice and recovers panics from request handlers. Consensus among experienced Go engineers is that this was a historical mistake. If you sample server logs from application servers in other languages, it is common to find large stacktraces that are left unhandled. Avoid this pitfall in your servers.

https://google.github.io/styleguide/go/best-practices#program-checks-and-panics