Skip to content
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
30 lines (23 sloc) 668 Bytes
package google
import (
google ""
// unexported key type prevents collisions
type key int
const (
userKey key = iota
// WithUser returns a copy of ctx that stores the Google Userinfoplus.
func WithUser(ctx context.Context, user *google.Userinfoplus) context.Context {
return context.WithValue(ctx, userKey, user)
// UserFromContext returns the Google Userinfoplus from the ctx.
func UserFromContext(ctx context.Context) (*google.Userinfoplus, error) {
user, ok := ctx.Value(userKey).(*google.Userinfoplus)
if !ok {
return nil, fmt.Errorf("google: Context missing Google User")
return user, nil
You can’t perform that action at this time.