Skip to content

proposal: cmd/go: warn if module uses features from next version of Go #67907

Closed
@Antonboom

Description

@Antonboom

Proposal Details

// go.mod        
module test

go 1.20
// main.go
package main

import (
    "fmt"
    "go/types"
)

func main() {
    fmt.Println(types.Unalias(nil))
}
$ go version
go version go1.22.2 darwin/arm64

$ go run main.go
<nil>

But! types.Unalias was appeared in Go 1.22.

And any other module >= Go 1.20 can use module above as dependency (according to new policy) but will receive compiler error like

main.go:9: undefined: types.Unalias

How can a developer check the version of your module to ensure that it does not contain features from the new toolchain (which may be installed as the latest version on the developer's machine)?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions