mmcgrana / gobyexample

Go by Example
https://gobyexample.com
7.16k stars 1.26k forks source link

Adding Go version requirement to certain new features in the language. #532

Closed Bakri-Hmouda closed 3 months ago

Bakri-Hmouda commented 3 months ago

Hello!

I have noticed that on the For page example, the following code example will throw a compiler error if you are using a Go version below 1.22.

Can we mention in a code comment that users need to update their Go version to try the code snippet?

Thank you!


//cannot range over 3 (untyped int constant)compiler[InvalidRangeExpr]
    for i := range 3 {
        fmt.Println("range", i)
    }
eliben commented 3 months ago

Thanks. I've added a note in the index page (text on top)