title: Golang serialize and deserialize back
body: <p>What's the best way (completeness and performance) in Golang to serialize and deserialize a struct to string and vice versa?</p>
  
  <p>for example, if I have this struct:</p>
  
  <pre><code>struct Session {
     Properties map[string]interface{}
     Permissions []int64
  }
  </code></pre>
  
  <p>I want to store it on <a href="http://github.com/garyburd/redigo/redis">Redis</a> and fetch it back. I have tried to save, int and string, it's fine, but how to store struct object?</p>
  
  <pre><code>conn := redisConnectors.Get()
  
  // set example
  
  _, err := conn.Do(`SETEX`, `uid_key`, EXPIRE_SEC, user_id)
  _, err = conn.Do(`SETEX`, `email_key`, EXPIRE_SEC, login_email)
  
  // get example
  
  user_id, err := redis.Int64(conn.Do(`GET`, `uid_key`))
  login_email, err := redis.String(conn.Do(`GET`, `email_key`))
  </code></pre>