Hm. For me, it still enables the rangefunc experiment, even though go.mod
says go 1.21:

mero@vetinari ~/tmp/x$ gotip version
go version devel go1.21-ca691a8566d Tue Jul 18 10:30:20 2023 -0400 (w/
rangefunc) linux/amd64
mero@vetinari ~/tmp/x$ cat go.mod
module x

go 1.21
mero@vetinari ~/tmp/x$ cat x.go
package main

import "fmt"

func main() {
    s := []int{1, 2, 3}
    for v := range All(s) {
        fmt.Println(v)
    }
}

func All[T any](s []T) func(yield func(T) bool) bool {
    return func(yield func(T) bool) bool {
        for _, v := range s {
            if !yield(v) {
                return false
            }
        }
        return true
    }
}
mero@vetinari ~/tmp/x$ gotip run x.go
1
2
3

On Fri, Aug 18, 2023 at 10:54 PM Hein Meling <hein.mel...@gmail.com> wrote:

> Hi all,
>
> I wanted to play around with the new range func CL
> <https://github.com/golang/go/issues/61405>.
>
> Doing simple stuff works just fine, but if I need to import packages to
> construct my custom iterator func, the go/gotip command insists on a go.mod
> file, which effectively resets the go version to 1.21.0 (due to go.mod),
> instead of the "(w/ rangefunc)" CL.
>
> Anyone know any workarounds for this?
>
> Thanks,
> :) Hein
>
> --
> You received this message because you are subscribed to the Google Groups
> "golang-nuts" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to golang-nuts+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/golang-nuts/f01ff376-b789-4d8a-89f5-165a6527325fn%40googlegroups.com
> <https://groups.google.com/d/msgid/golang-nuts/f01ff376-b789-4d8a-89f5-165a6527325fn%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/CAEkBMfEcs_jjH29FUA_sVd%2BFRbNPGy3Tq96kam7peSTVGfNgSA%40mail.gmail.com.

Reply via email to