App.go
package main import ( "fmt" "net/http" ) func main() { url := "https://self-learning-java-tutorial.blogspot.com" contentType, err := contentType(url) if err != nil { fmt.Println(err) return } fmt.Println("Content Type : ", contentType) } func contentType(url string) (string, error) { resp, err := http.Get(url) if err != nil { return "", err } defer resp.Body.Close() cType := resp.Header.Get("Content-Type") return cType, nil }
Output
Content
Type : text/html; charset=UTF-8
No comments:
Post a Comment