5 ms·
Go Analysis Framework: modular static analysis by go team
- hoppp 2mo agoI was just looking for this. Will give it a spin.
- jamescun 2mo agoThis isn't new? You can see it's used by _a lot_ of linters already: https://pkg.go.dev/golang.org/x/tools/go/analysis?tab=importedby https://pkg.go.dev/golang.org/x/tools/go/analysis?tab=import...
- dfasifsaf 2mo ago[flagged]
- deleted 2mo ago[deleted]
- zikohh 2mo agoIt's spam look at the users history. They just comment the same thing everywhere
- zahlman 2mo agoThis is another instance of a spam attack I first noted over a year ago. New accounts all set up to keep linking to this one particular Stack Overflow question. Ref. https://meta.stackoverflow.com/questions/433930/repeated-waves-of-misleading-off-site-inbound-links-all-to-the-same-question https://meta.stackoverflow.com/questions/433930/repeated-wav...
- someworkk 2mo ago[flagged]
- b7e7d855b448 2mo agoYou guys can keep complaining about how go is too verbose, but I love everything about go. I love the error handling, I love the forced formatting, i love all the linting it has including style guides. When you read other source code it's so easy to understand it and make sense of it. Thank you go team (Ok, maybe I am a bit sceptical with the latest generic additions, but overall it's a great language. I love it.)
- jerf 2mo agoIf generics were going to ruin the language, they would have by now. I think you can rest easy.
- ncruces 2mo agoThe greatest thing about generics is … that they're not used much if at all. Which is a great way to make sure they're not overused, which in my experience is better than underuse.
- wannabe44 2mo agoOh yeah totally agree. I don't understand why someone would want to write `slices.Contains(s, needle)` when you can write this beautiful poem like a Shakespeare in VSCode: found := false for _, v := range s { if v == needle { found = true break } } Oh and I totally want to build a stack trace manually. It's like doing cardio to me. if err != nil { return fmt.Errorf("my function name but in spaces: %w", err); } This is very elegant by the way, so that we need errors.Is now, which has to dynamically check if the error implements Unwrap() error or Unwrap() []error. Because having any language facilities for error handling is harmful.
- logicchains 2mo agoYour handwritten one has a major performance bug: found := false for _, v := range s { if v == needle { found = true break } } Do you see it? It copies the v into a local variable, which could be tremendously wasteful if it's a large struct. You should instead be taking a pointer to s[i] and comparing the value there with `needle`. If you'd used `slices.Contains(s, needle)`, on the other hand, it could have such a performance bug in it and you'd never know.
- ksec 2mo agoSo what is context? This isn't new and why the submission ?
- hxtk 2mo agoSomeone in the thread about the Ruff update ingenuously said they wished Go had something like Ruff, being unaware of this framework. In that thread, someone seemed to take it as a sign that many people who might care to know about this don't yet, so they made a dedicated post for it.
- ksec 2mo agoThanks
- k9294 2mo ago[flagged]
- jzelinskie 2mo agoFor SpiceDB[0], we've found a lot of success using this framework to define our own analyzers; it's probably 10x easier now with LLMs. No need for tribal knowledge or more time wasted on code review if you can just turn it into a linter and move on. [0]: https://github.com/authzed/spicedb/tree/main/tools/analyzers https://github.com/authzed/spicedb/tree/main/tools/analyzers
- verdverm 2mo agoThe Go team's emphasis on tooling in the service of software engineering is a boon to human and agentic development alike. Give yourself and your agents great tools. An example from one of my recent projects: https://github.com/verdverm/gmd/blob/main/Makefile https://github.com/verdverm/gmd/blob/main/Makefile (give agents simple "tool calls" instead of needing to divine the correct args/flags every time, essentially invocable agents.md content) One of the interesting things to call out from this is using build tags for testing { unit, coverage, recorded, real api }, with the buffet allowing the agent to iterate faster and more targeted. I tend to run the linting and coverage in a new session, have a report generated, and then another fresh session to start dealing with gaps. Another super cool testing tool in the Go internal source is `testscript`. Roger Peppe extracted a number of those internal utilities here https://github.com/rogpeppe/go-internal/tree/master/testscript https://github.com/rogpeppe/go-internal/tree/master/testscri...
- mchav 2mo agoCan these sorts of primitives be used to create broader "architectural" linters?
- fractorial 2mo agoYes, and I use them often in the context of writing adversarial ‘go vet’ style anti-slop analyzers that run pre-commit.
- neet_dev 2mo ago[flagged]
- greatsage_sh 2mo ago[flagged]
- bijowo1676 2mo agothe most valuable thing in this article for me was this: The early loop looked like this: /goal improve the perf by 20% -> a great deal of plausible code -> a confusing benchmark -> another plausible patch Later it looked like this: find the expensive work -> explain why it happens -> change one mechanism -> compare with the previous Rust revision -> test the complete application -> retain, revise, or reject
- ridiculous_fish 2mo ago[dead]
- eonwe 2mo agoThis is one of the least informative discussions in HN front page that I remember.