Skip to content

Instantly share code, notes, and snippets.

@TheDudeWithTheThing
Created September 6, 2013 19:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save TheDudeWithTheThing/6468746 to your computer and use it in GitHub Desktop.
Save TheDudeWithTheThing/6468746 to your computer and use it in GitHub Desktop.
A simple function for Go (golang) projects on Heroku using Redis To Go. It pulls the environment var REDISTOGO_URL and returns the server:port and password part of it for use with redis clients. Used in my project to learn Go at https://github.com/TheDudeWithTheThing/quotient-quotables
func ParseRedistogoUrl() (string, string) {
redisUrl := os.Getenv("REDISTOGO_URL")
redisInfo, _ := url.Parse(redisUrl)
server := redisInfo.Host
password := ""
if redisInfo.User != nil {
password, _ = redisInfo.User.Password()
}
return server, password
}
@dimitrismistriotis
Copy link

Hi. I have a hard time trying this (probably something else going wrong). http://stackoverflow.com/questions/25831869/golang-redis-error-on-heroku Does the parsing still work? What happens with the username? Thanx

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment