imported but undefined? Go

go, http, import, package

Solution

The package you want to import is called `"net/http"`, not `"http"`. Try:

import (
    "net/http"
)

Problem

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?

Original source

Related problems