Hacker Newsnew | past | comments | ask | show | jobs | submit | zarldev's commentslogin

In standard go you would not implement Is but would use the errors.Is call. How would this work if it is a sentinel error as you would use with errors.Is??


https://pkg.go.dev/errors#Is

> An error is considered to match a target if it is equal to that target or if it implements a method Is(error) bool such that Is(target) returns true.

by default errors.Is matches the exact error variable, but you can use it to match other errors as well.


I stand corrected. Still you cannot implement an Is on a sentinel error and is only applicable to concrete error types. And if I'm using concrete types I'm going to us errors.As


>That's it mostly...

Whole kubernetes, docker, traefik and many other cloud native tools are written in go.


They are my daily bread and I sloppily lumped them in with "web [...] services", but in hindsight they ought to be a separate category - fundamentally about a different layer,infrastructure, and might not even be networked.


Many tools on DevOps ecosystem are now going through the RIIR phenomenon, and I bet, had Rust 1.0 been available when Kubernetes decided to migrate away from Java, after Go heads joined the team (see FOSDEM talk on the matter), or Docker moving away from Python, most of those tools would have been written in Rust instead.


> most of those tools would have been written in Rust

I seriously doubt it for the same reason that Google, with all of its expertise and tooling for it, didn't choose C++, twice.


You may doubt it, I keep my certainty, given how much Go is being used at Google, versus Java, Kotlin, C++ and Rust.


The Rust of today wouldn't be chosen over the Go of a decade ago, it is fundamentally a bad fit, for similar reasons that the already mature C++ wasn't. Java (similar to C#) would've been viable mainly due to maturity and ecosystem effects, Kotlin/Native might be a contender in another half decade, sooner if the team were to shift priorities.

I say this not just for Kubernetes etc., but greenfield projects today as well.


Meanwhile on the field,

https://deislabs.io/posts/still-rusting-one-year-later/

I gather you are aware of Deis Labs history, Microsoft acquisition and such, do you want other CNCF companies that have pivoted into Rust?


More like, an attempt in the field from 2 years ago

> [Warning] This project is currently not actively maintained.

But there is a library by them to build containerd shims with which is maintained: https://github.com/containerd/runwasi

Let's just entertain the idea and pretend that this is a notable project and that one would count it as DevOps tooling. Here are the top 10 across the CNCF in terms of size, courtesy of GitHub's API:

    C++: 3195829832
    Java: 2908175049
    Go: 2005598094
    C: 1225503783
    Python: 931070259
    LLVM: 594277917
    C#: 484071185
    Rust: 460427159
    TypeScript: 428904119
    JavaScript: 273074800
This is the best-case scenario, including irrelevant categories like databases and VMMs that ought to be written in Rust (or C++).

As far as Microsoft itself goes, they have a new push to ~~lock-in~~ embrace and extend cloud customers:

https://blog.radapp.io/posts/2024/04/16/radius-accepted-as-c...

As far as recent projects that gained traction with the CNCF go, I found some nice write-ups:

https://blog.palark.com/cncf-sandbox-2023-h1/

https://blog.palark.com/cncf-sandbox-2023-h2/

https://blog.palark.com/cncf-sandbox-2024-h1/

    Go: 30
    Rust: 4 (once to implement another lang)
    Python: 2
    Java: 1
    and 2 that are mixed (Go+{C,Rust})
Fun fact, one of the 30 is Eraser - by Deis Labs.


Yeah extending the struct tags to iota definitions would have made things much better.


the values are specified in the definition of the iota type.

``` type planet int // Gravity[float64],RadiusKm[float64],MassKg[float64],OrbitKm[float64],OrbitDays[float64],SurfacePressureBars[float64],Moons[int],Rings[bool] ```


yeah, and now, mentally count how many values you are in, don't lose count now! Why offload that to your brain where you could miscount instead of using structured data?


Because your whole argument is misconstructed. There are cases where longer code is better, but there are many cases where longer is worse too. Because the tools the language provide, on top of being more succint, make the intent more obvious.


This should be better now.


DSL? The go way is to use go generate I would say and it can be used with go:generate, I would like to use the AST lib to parse go files to remove the need for any json and to be more like the cmd stringer tool.


Yes. Your DSL is JSON in this case,

{ "enums": [ { "package": "cmd", "type": "operation", "values": [ "Escalated", "Archived", "Deleted", "Completed" ] } ] }

My point was the "Go" way to do this isn't parsing a custom format (like your JSON), but it's to use go generate.


But all go generate does is run a binary like stringer? This can be used in go generate.


I'm not sure I understand exactly what you mean, but you can combine go:generate with go run so you can execute code from the current module/project that does what you want.

//go:generate go run ./internal/enumhelper -flag1 -flag2


Hey did you read to the bottom of the article. It shows that that was just a temporary solution, the real invalid code is

func (t operation) IsValid() bool { _, ok := strOperationMap[s] return ok }

Tbh it has been updated to us an array instead for string indexing.


Consider applying for YC's Summer 2026 batch! Applications are open till May 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: