go - Golang "net/http" Error: undefined: DetectContentType -
the "net/http" package implements function detectcontenttype
http://golang.org/pkg/net/http/#detectcontenttype
but when try use it, error undefined: detectcontenttype
package main import ( "fmt" "io/ioutil" "log" "net/http" ) func main() { res, err := http.get("http://www.google.com/robots.txt") if err != nil { log.fatal(err) } robots, err := ioutil.readall(res.body) res.body.close() if err != nil { log.fatal(err) } filetype := detectcontenttype(robots) fmt.println("filetype: ", filetype) }
https://play.golang.org/p/wjduu8xx-5
what doing wrong?
it part of "net/http" package therefore have write,
http.detectcontenttype(robots)
note if wanted use function in way change import statement such:
import ( ... . "net/http" )
Comments
Post a Comment