Install the "context" package in golang?

I am trying to install the context package in golang which I liked:

 go get golang.org/x/net/context 

But when I do import "context" , I still get the following error:

 cannot find package "context" in any of: /usr/lib/go-1.6/src/context (from $GOROOT) /home/saurabh/work/src/context (from $GOPATH) 

Can anyone suggest how to install this package? I am currently using version go1.6.2 .

+7
go
source share
1 answer

change import "context" to import "golang.org/x/net/context" .

but after jump 1.7 you can use import "context" as it has become a standard library.

Go 1.7 moves the golang.org/x/net/context package to the standard library as a context.

see release notes for 1.7: https://golang.org/doc/go1.7#context

+12
source share

All Articles