Created
September 6, 2013 19:29
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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