Skip to content

Instantly share code, notes, and snippets.

@c1982
Created March 29, 2019 23:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save c1982/c31214de2dd2726544d7e32bc866c013 to your computer and use it in GitHub Desktop.
Save c1982/c31214de2dd2726544d7e32bc866c013 to your computer and use it in GitHub Desktop.
Example for my blog post
package main
import (
"crypto/md5"
"fmt"
"net/http"
)
var Version string
func main() {
fmt.Println("version:", Version)
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
fmt.Fprintf(w, hash(r.URL.Query().Get("q")))
})
http.ListenAndServe(":8080", nil)
}
func hash(input string) string {
return fmt.Sprintf("%x", md5.Sum([]byte(input)))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment