On Wed, Aug 11, 2021 at 5:44 PM
tapi...@gmail.com <
tapi...@gmail.com> wrote:
>
> But by not specifying the language version in go.mod, I think most people would expect to use the latest features.
> In other words, the default language version gc uses should be the same as the version of the toolchain containing gc.
I believe it is. If I run "go mod init" then in the result go.mod
> On Wednesday, August 11, 2021 at 4:46:06 PM UTC-4 Ian Lance Taylor wrote:
>>
>> On Wed, Aug 11, 2021 at 7:45 AM
tapi...@gmail.com <
tapi...@gmail.com> wrote:
>> >
>> > // main.go
>> > package main
>> >
>> > func main() {
>> > var s = []int{1, 2, 3}
>> > var pa = (*[2]int)(s[1:])
>> > println(pa[1])
>> > }
>> >
>> > $ go run main.go
>> > # command-line-arguments
>> > ./main.go:6:23: cannot convert s[1:] (type []int) to type *[2]int:
>> > conversion of slices to array pointers only supported as of -lang=go1.17
>> >
>> > Is it the deliberate design? Shouldn't the lang value be the highest language version supported by the current used toolchain?
>>
>> This is deliberate design. The idea is that if you put "go 1.16" in
>> your go.mod file you can reasonably assume that your package will be
>> usable by people who are still using Go 1.16. If you don't care
>> whether those people can build your package, go ahead and change to
>> 1.17.
>>
>> Ian
>
> --
> 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...@googlegroups.com.