I want to use "http" package, and try to import
package main
import (
    "http"
)
func main() {
    resp, err := http.Get("https://api.github.com/repos/otiai10/myFirstGo")
    if err != nil {
        // do something
    }
    if resp != nil {
        // do something
    }
}
and got outputs below
% go run httpget.go
# command-line-arguments
./httpget.go:4: imported and not used: "http"
./httpget.go:8: undefined: http
I saw this question : Strange golang package import issue
Is this the same problem? or did I use 'import' or 'http' in wrong way?
The package you want to import is called "net/http", not "http".  Try:
import (
    "net/http"
)
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With