Skip to content

Instantly share code, notes, and snippets.

@dgv
Last active April 23, 2017 01:04
Show Gist options
  • Save dgv/6085126 to your computer and use it in GitHub Desktop.
Save dgv/6085126 to your computer and use it in GitHub Desktop.
Gravatar image
// 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 = "danielgvargas@gmail.com"
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