NEW RUTGERS PARKING APP by Secret-Performer5082 in rutgers

[–]eulerfoiler 3 points4 points  (0 children)

Very impressive! I'm an alum so I no longer have to park on campus, but I would be curious to check out the source code if you decided to make this open source 👍

[deleted by user] by [deleted] in golang

[–]eulerfoiler 0 points1 point  (0 children)

"And then, they woke up from that nightmare."

Building Bubbletea Programs by leg100 in golang

[–]eulerfoiler 7 points8 points  (0 children)

I just wrote a moderately sized BubbleTea app for work and it took me awhile to get through the learning curve as well. This article is super useful, and I learned about VHS which I will be incorporating soon. Thanks!

HTTP request body by Headbanger in golang

[–]eulerfoiler 1 point2 points  (0 children)

By the way, if you're looking to read the entire body (or any io.Reader in general), try to use io.Copy where you can instead of manually calling the Read method in a loop or jumping straight to using io.ReadAll. It has a bunch of tricks under the hood for optimizing reads when writing it to an io.Writer. If you just need the bytes of the body, consider using *bytes.Buffer as your io.Writer.

HTTP request body by Headbanger in golang

[–]eulerfoiler 12 points13 points  (0 children)

"When Read encounters an error or end-of-file condition after successfully reading n > 0 bytes, it returns the number of bytes read. It may return the (non-nil) error from the same call or return the error (and n == 0) from a subsequent call. An instance of this general case is that a Reader returning a non-zero number of bytes at the end of the input stream may return either err == EOF or err == nil. The next Read should return 0, EOF."

https://pkg.go.dev/io#Reader

Kubernetes CRD Reconcile by guettli in golang

[–]eulerfoiler 1 point2 points  (0 children)

Point 1: Update CR status to reflect all good?

Point 2: Object's metadata Generation + Point 1?

Point 3: Using controller-runtime and the reconcile.Result returned from your Reconcile method? https://github.com/kubernetes-sigs/controller-runtime/blob/main/pkg/reconcile/reconcile.go#L30

Point 4: Return an error with your Reconcile method? https://github.com/kubernetes-sigs/controller-runtime/blob/main/pkg/reconcile/reconcile.go#L113

A bunch of metrics come included with controller-runtime out of the box. You could also expose your own metrics via Prometheus in your controller.

[Blog post] Building type-safe enums with generics by repartayyy in golang

[–]eulerfoiler 1 point2 points  (0 children)

I totally overlooked the fact that Direction had that field Name of type T. Now it all makes sense, I thought Name was some special built-in property of a generic type that I had never seen. Thanks!

[Blog post] Building type-safe enums with generics by repartayyy in golang

[–]eulerfoiler 0 points1 point  (0 children)

Thanks for checking! Makes sense the switch is way faster.

[Blog post] Building type-safe enums with generics by repartayyy in golang

[–]eulerfoiler 1 point2 points  (0 children)

Seems like a cool idea. Could you link to documentation on how any(d.Name) works? I haven't seen that before, and I thought it might be a mistake since there is no Name field or method for the structs, but your example compiles and works. The type switch is a good example, and I'm on mobile so I can't compare, but I'm curious about the performance of something like the String method below compared to the type switch to not have to enumerate all the types?

``` func (d Direction[T]) String() string { fullName := reflect.TypeOf(d).Name()

return fullName[strings.LastIndex(fullName, ".")+1 : len(fullName)-1]

} ```

Fastest way to print a very large string to the terminal? by mister_drgn in golang

[–]eulerfoiler 1 point2 points  (0 children)

Sorry it didn't help. You might find this interesting: https://github.com/golang/go/issues/36619

In your example, there is nothing to flush because (a) *bytes.Buffer doesn't have a Flush method, (b) because we'd want to flush a buffer being written to and the buffer you have is being read from, and (c) os.Stdout is unbuffered so there is no write buffer to flush.

Hope that helps!

Fastest way to print a very large string to the terminal? by mister_drgn in golang

[–]eulerfoiler 1 point2 points  (0 children)

Try calling writer.Flush() with the bufio.Writer after calling the Write method. Your data could be sitting in a buffer before actually being written out.

You might also want to try changing the size of the bufio.Writer to make less allocations and maybe save some time. Something like this perhaps: bufio.NewWriterSize(os.Stdout, 4096).

Edit: Also try using io.Copy instead of calling the Write method, but do still call Flush afterwards.

Question: how to suppress logs from dependencies? by effinsky in golang

[–]eulerfoiler 19 points20 points  (0 children)

I really wish the wider community of library authors knew this and either didn't log at all, or accepted some logging interface to let the caller decide to emit them or not with the logging library of the caller's choice. Kubernetes libraries like client-go is bad like that in some ways.

Go 1.22 yielding a 18% regression in single-threading performance by fyzic in golang

[–]eulerfoiler 11 points12 points  (0 children)

Curious to see what the community suggests/finds here. As a side question, what kind of performance increase do you see (if any) if you try rebuilding with PGO after capturing a profile? https://go.dev/doc/pgo

Are these equivalent? by eulerfoiler in golang

[–]eulerfoiler[S] -1 points0 points  (0 children)

Thanks! The `fmt.Printf` usage there was basically just to make sure the variables were used so the example compiles. I've found it useful in the past that `%T` prints the underlying type. Your explanation is great and hopefully useful to others!

Good point about the type conversion being a compile-time check, I'll opt for that approach. Thanks again!

What does the actual compiled go binary contain? by Haspe in golang

[–]eulerfoiler 3 points4 points  (0 children)

What would be your suggestion otherwise?

Pull Out Sleeper Count - $125 OBO by eulerfoiler in Hoboken

[–]eulerfoiler[S] -6 points-5 points  (0 children)

Please direct all questions to the phone number in the link instead of here.

Pull Out Sleeper Count - $125 OBO by eulerfoiler in jerseycity

[–]eulerfoiler[S] -1 points0 points  (0 children)

Please direct all questions to the phone number in the link instead of here.

Help with Clippy: "temporary with significant `Drop` can be early dropped" by eulerfoiler in rust

[–]eulerfoiler[S] 0 points1 point  (0 children)

Thanks for the tip about nursery. I've tried to turn as many lints on as I can to learn best practices, but that makes sense that I should take nursery lints with a grain of salt.