title: Implementing Redigo Scanner interface on a struct's field
body: <p>I have a struct that looks like this:</p>
  
  <pre><code>type authEnum int
  
  const (
      never authEnum = iota
      sometimes
      always
  )
  
  type Attrs struct {
      Secret         string   `redis:"secret"`
      RequireSecret  authEnum `redis:"requireSecret"`
      UserID         string   `redis:"userId"`
  }
  
  func (e *authEnum) RedisScan(src interface{}) error {
      // This never gets called!
      if e == nil {
          return fmt.Errorf("nil pointer")
      }
      switch src := src.(type) {
      case string:
          if src == "false" || src == "never" {
              *e = never
          } else if src == "sometimes" {
              *e = sometimes
          } else { // "always" or "true"
              *e = always
          }
      default:
          return fmt.Errorf("cannot convert authEnum from %T to %T", src, e)
      }
      return nil
  }
  
  func getAttributes(ctx *AppContext, hash string) (*Attrs, error) {
      rc := ctx.RedisPool.Get()
      values, err := redis.Values(rc.Do("HGETALL", "redishash"))
      rc.Close()
      if err != nil {
          return nil, err
      }
      attrs := Attrs{}
      redis.ScanStruct(values, &amp;attrs)
      return &amp;attrs, nil
  }
  </code></pre>
  
  <p>How do I implement the <a href="https://godoc.org/github.com/garyburd/redigo/redis#Scanner" rel="nofollow noreferrer">Scanner</a> interface on the <code>RequireSecret</code> attribute to parse an <code>authEnum</code> type out of <code>"never"</code>, <code>"sometimes"</code> or <code>"always"</code> redis hash values?</p>
  
  <p>How do I calculate the value and assign it to the authEnum?
  In my code example <code>RedisScan</code> never gets called.</p>