Last active
April 23, 2017 01:04
-
-
Save dgv/6085126 to your computer and use it in GitHub Desktop.
Gravatar image
This file contains hidden or 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
// Gravatar image | |
// http://en.gravatar.com/site/implement/ | |
// Run it: http://go-vim.appspot.com/p/oAsi0WvLlf | |
package main | |
import ( | |
"crypto/md5" | |
"fmt" | |
"io" | |
"strings" | |
) | |
const email = "[email protected]" | |
func main() { | |
// create the md5 hash | |
hash := md5.New() | |
// get the email from URL-parameters or what have you and make lowercase | |
io.WriteString(hash, strings.ToLower(email)) | |
// compile URL which can be used in <img src="RIGHT_HERE"... | |
fmt.Printf("%s avatar image link: http://www.gravatar.com/avatar/%x", email, hash.Sum(nil)) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment