Created
March 29, 2019 23:21
-
-
Save c1982/c31214de2dd2726544d7e32bc866c013 to your computer and use it in GitHub Desktop.
Example for my blog post
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
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