Live data from Hacker News

Go 1.23 Released

go.dev

61–70 of 106 posts

Re: Go 1.23 Released

#61
post #34

If you find the official release notes a bit dry (they really are), I've prepared an interactive version with lots of examples: - Iterators (range / types / pull / slices / maps). - Timer changes (garbage collection and reset/stop behavior). - Canonical values with the `unique` package. - HTTP cookie handling. - Copying directories. - Slices and atomics changes. https://antonz.org/go-1-23

I want to understand the purpose of maps.All().

In the example:

  m := map[string]int{"a": 1, "b": 2, "c": 3}
  
  for k, v := range maps.All(m) {
   fmt.Printf("%v:%v ", k, v)
  }
  
  fmt.Println("")
  
  for k, v := range m {
   fmt.Printf("%v:%v ", k, v)
  }
These both output the same thing. What's the point of the addition?

Slices.All() seems similarly redundant and pointless.

Surely I must be misunderstanding something, I hope.

Re: Go 1.23 Released

#62
post #20

Any good resources on learning go? Has anyone had any luck with the YT videos or courses way?

I hope I don't sounds rude saying this but Go code is generally self evident. I personally got my Go knowledge from reading Go code on GitHub or the like. There's a certain beauty to Go code in that you can grasp what code does pretty easily, which definitely helps with learning.

I wouldn't say that's true, I personally find Go code more confusing to read than the average language. For example:

``` func (r rect) area() int { return r.width r.height } ```

This syntax is strange to me despite being a simple example. I can tell that it's a function that takes in a rect pointer, is maybe named area() (but I'm now confused why this definition doesn't have an argument?), and returns an integer value. I've tried reading larger Go files and constantly run into syntax confusion like this and get exhausted.

So sure, I understand the gist of this code, but this is more difficult to understand IMO than any Python, Ruby, Java, Swift, Rust, Gleam code I've read.

Re: Go 1.23 Released

#63

I don't like the "range-over-func" addition. I feel like it is adding complexity and syntactic sugar to the language that has thus far been mostly avoided.

Hard disagree. A standard way to define iterators was long overdue, and using the existing `range` construct was the right solution.

This change will end up removing some mental load, at an extremely low complexity cost. Basically you define an iterator just by defining a function. No additional keyword, no state to manage, just a function.

Re: Go 1.23 Released

#64
post #61
post #34

If you find the official release notes a bit dry (they really are), I've prepared an interactive version with lots of examples: - Iterators (range / types / pull / slices / maps). - Timer changes (garbage collection and reset/stop behavior). - Canonical values with the `unique` package. - HTTP cookie handling. - Copying directories. - Slices and atomics changes. https://antonz.org/go-1-23

I want to understand the purpose of maps.All(). In the example: m := map[string]int{"a": 1, "b": 2, "c": 3} for k, v := range maps.All(m) { fmt.Printf("%v:%v ", k, v) } fmt.Println("") for k, v := range m { fmt.Printf("%v:%v ", k, v) } These both output the same thing. What's the point of the addition? Slices.All() seems similarly redundant and pointless. Surely I must be misunderstanding something, I hope.

They’re useful because they let you pass a slice or map to something built to handle the new func(func (…) bool) style iterators.

If I create a IterateOver(fn func(func (K, V any) bool)) function, you cannot pass a slice since that doesn’t match fn’s type, but if you wrap it with slices.All it’ll work.

Re: Go 1.23 Released

#65
post #11

As someone who was advocating for a similar warning in Rust (finally added to clippy in 1.78), I'm glad to see this improvement in `go vet` > The go vet subcommand now includes the stdversion analyzer, which flags references to symbols that are too new for the version of Go in effect in the referring file. (The effective version is determined by the go directive in the file’s enclosing go.mod file, and by any //go:bu…

Don't most Rust crates solve this by running MSRV builds/tests?

Or is the goal to catch it eg. in precommit hook?

Re: Go 1.23 Released

#66
post #61
post #34

If you find the official release notes a bit dry (they really are), I've prepared an interactive version with lots of examples: - Iterators (range / types / pull / slices / maps). - Timer changes (garbage collection and reset/stop behavior). - Canonical values with the `unique` package. - HTTP cookie handling. - Copying directories. - Slices and atomics changes. https://antonz.org/go-1-23

I want to understand the purpose of maps.All(). In the example: m := map[string]int{"a": 1, "b": 2, "c": 3} for k, v := range maps.All(m) { fmt.Printf("%v:%v ", k, v) } fmt.Println("") for k, v := range m { fmt.Printf("%v:%v ", k, v) } These both output the same thing. What's the point of the addition? Slices.All() seems similarly redundant and pointless. Surely I must be misunderstanding something, I hope.

[deleted]

Re: Go 1.23 Released

#67
post #29
post #3

Opt-in telemetry. A very rare sight these days. Glad to see. Not even Mozilla does that with Firefox [1]. > Starting in Go 1.23, the Go toolchain can collect usage and breakage statistics that help the Go team understand how the Go toolchain is used and how well it is working. We refer to these statistics as Go telemetry. > Go telemetry is an opt-in system, controlled by the go telemetry command. By default, the tool…

I'm open to being convinced otherwise, but I feel like I'm the only one who doesn't get why opt-out telemetry is such a big deal. Sure, if it's a software library, I don't want it doing random network calls during my runtime. That's just rude. But if it's a user application (including a compiler), I don't see what the fuss is about. Of all the myriad of ways our data is harvested every single day, telemetry seems ver…

You don’t know what they are sending. Maybe today it is innocuous data. Tomorrow, they ship off your ssh keys.

Better to default deny all.

Re: Go 1.23 Released

#68
post #61
post #34

If you find the official release notes a bit dry (they really are), I've prepared an interactive version with lots of examples: - Iterators (range / types / pull / slices / maps). - Timer changes (garbage collection and reset/stop behavior). - Canonical values with the `unique` package. - HTTP cookie handling. - Copying directories. - Slices and atomics changes. https://antonz.org/go-1-23

I want to understand the purpose of maps.All(). In the example: m := map[string]int{"a": 1, "b": 2, "c": 3} for k, v := range maps.All(m) { fmt.Printf("%v:%v ", k, v) } fmt.Println("") for k, v := range m { fmt.Printf("%v:%v ", k, v) } These both output the same thing. What's the point of the addition? Slices.All() seems similarly redundant and pointless. Surely I must be misunderstanding something, I hope.

You can use it with other functions that use iterators. For example, here is code that makes a copy of a map keeping only the even keys.

  maps.Collect(xiter.Filter2(func(k, v int) bool { return k%2 == 0 }, maps.All(m)))

Re: Go 1.23 Released

#69
post #3

Opt-in telemetry. A very rare sight these days. Glad to see. Not even Mozilla does that with Firefox [1]. > Starting in Go 1.23, the Go toolchain can collect usage and breakage statistics that help the Go team understand how the Go toolchain is used and how well it is working. We refer to these statistics as Go telemetry. > Go telemetry is an opt-in system, controlled by the go telemetry command. By default, the tool…

> Opt-in telemetry. A very rare sight these days. Glad to see. Ahem. Cough. Given Google's ties to Go, of course it was NOT opt-in when originally announced. After, shall we say, a "lively" discussion on the relevant Github topic[1], it was changed to opt-in. :D Opt-in is the correct stance. [1] https://github.com/golang/go/discussions/58409

there's infinity things to criticise google for, but "the go team want useful metrics" isn't one of them.

Re: Go 1.23 Released

#70
post #44

Earlier quoted context omitted.

You put your cursor on the "Range" portion of m.Range, and hit "Jump to Definition". You can also just not import things that do crazy things with iterators. Based on the history of the community, that will actually be fairly easy. I'm yet to see anything crazy with generics get into a library that I use. I'm abundantly positive there's going to be a dozen "hey let's go do crazy things with rangefunc" libraries in th…

> You put your cursor on the "Range" portion of m.Range, and hit "Jump to Definition". Well, that's one reason why people usually run away from languages high in magic like Java/JS to something like Go: not needing a fancy IDE to make sense of what's happening with a single line of code.

[flagged]
Post reply on HN