Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(518)

Issue 104480044: code review 104480044: go.net/context: remove the Key type; replace it with st... (Closed)

Can't Edit
Can't Publish+Mail
Start Review
Created:
9 years, 10 months ago by Sameer Ajmani
Modified:
9 years, 10 months ago
Reviewers:
crawshaw
CC:
golang-codereviews, crawshaw, dsymonds, rsc
Visibility:
Public.

Description

go.net/context: remove the Key type; replace it with interface{}. This makes the Context interface dependent only on standard packages, which means types in other packages can implement this interface without depending on go.net/context. Remove the NewKey function and add examples showing how to use unexported types to avoid key collisions. This is the same model used by http://www.gorillatoolkit.org/pkg/context, except we associate values with a specific Context instead of storing them in a package-level map.

Patch Set 1 #

Total comments: 5

Patch Set 2 : diff -r 28ff664507e4 https://code.google.com/p/go.net #

Total comments: 6

Patch Set 3 : diff -r 28ff664507e4 https://code.google.com/p/go.net #

Patch Set 4 : diff -r 28ff664507e4 https://code.google.com/p/go.net #

Unified diffs Side-by-side diffs Delta from patch set Stats (+107 lines, -98 lines) Patch
M context/context.go View 1 2 5 chunks +81 lines, -86 lines 0 comments Download
M context/context_test.go View 1 1 chunk +26 lines, -12 lines 0 comments Download

Messages

Total messages: 8
Sameer Ajmani
Hello golang-codereviews@googlegroups.com, I'd like you to review this change to https://code.google.com/p/go.net
9 years, 10 months ago (2014-07-02 02:00:28 UTC) #1
crawshaw
LGTM https://codereview.appspot.com/104480044/diff/1/context/context.go File context/context.go (right): https://codereview.appspot.com/104480044/diff/1/context/context.go#newcode47 context/context.go:47: // // package foo defines a value that's ...
9 years, 10 months ago (2014-07-02 15:00:47 UTC) #2
dsymonds
https://codereview.appspot.com/104480044/diff/1/context/context.go File context/context.go (right): https://codereview.appspot.com/104480044/diff/1/context/context.go#newcode36 context/context.go:36: // panics if the import path or name are ...
9 years, 10 months ago (2014-07-03 01:28:58 UTC) #3
Sameer Ajmani
The duplicate detection in NewKey is intended to help catch when two different packages register ...
9 years, 10 months ago (2014-07-07 02:52:19 UTC) #4
Sameer Ajmani
Substantial revision and simplification. Keys are now interface{}, so users can define unexported types to ...
9 years, 10 months ago (2014-07-10 14:20:22 UTC) #5
crawshaw
LGTM https://codereview.appspot.com/104480044/diff/20001/context/context.go File context/context.go (right): https://codereview.appspot.com/104480044/diff/20001/context/context.go#newcode84 context/context.go:84: // Use context values only for request-scoped data ...
9 years, 10 months ago (2014-07-10 18:35:40 UTC) #6
Sameer Ajmani
https://codereview.appspot.com/104480044/diff/20001/context/context.go File context/context.go (right): https://codereview.appspot.com/104480044/diff/20001/context/context.go#newcode84 context/context.go:84: // Use context values only for request-scoped data that ...
9 years, 10 months ago (2014-07-10 18:57:14 UTC) #7
Sameer Ajmani
9 years, 10 months ago (2014-07-10 18:57:28 UTC) #8
*** Submitted as
https://code.google.com/p/go/source/detail?r=335bcad0b70a&repo=net ***

go.net/context: remove the Key type; replace it with interface{}.  This
makes the Context interface dependent only on standard packages, which
means types in other packages can implement this interface without
depending on go.net/context.

Remove the NewKey function and add examples showing how to use
unexported types to avoid key collisions.  This is the same model used
by http://www.gorillatoolkit.org/pkg/context, except we associate values
with a specific Context instead of storing them in a package-level map.

LGTM=crawshaw
R=golang-codereviews, crawshaw, dsymonds
CC=golang-codereviews, rsc
https://codereview.appspot.com/104480044
Sign in to reply to this message.

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b