package controllers import ( "crypto/md5" "fmt" "io" "io/ioutil" "net/http" ) func HashUrl(url string) (string, error) { response, err := http.Get(url) if err != nil { return "Get request failed.", err } defer response.Body.Close() contents, err := ioutil.ReadAll(response.Body) if er != nil { return "Reading body failed.", err } h := md5.New() io.WriteString(h, string(contents)) hash := fmt.Sprintf("%x", h.Sum(nil)) return hash, nil }