Skip to content

proposal: spec: make context.Context a predefined type like error #20282

@dsnet

Description

@dsnet

Split from #20280, @rasky @zombiezen

Should context.Context be part of the language? Currently, error is an interface type defined in the language and is a pervasive type that is commonly returned from functions. The context.Context type can be seen as sort of the reverse of error, where it is a pervasive type that is commonly passed to functions.

However, one challenge with the context.Context interface is that the Context.Deadline method returns a time.Time, which probably should not be promoted to the language itself.

Personally, I can see the opposite being more likely: that error be pulled out of the language specification and instead be defined in the errors package. (In fact, it used to be a library defined type as os.Error).

It would be consistent if context.Context and error were given equal treatment from the perspective of the language in Go2.

Go ahead and discuss.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions