Search code examples
godatastore

I can't import "cloud.google.com/go/datastore"


I can't understand why this :/

I tried go get -u ** with every url that I found. Thanks

Golang:

$ go version
go version go1.13.3 windows/amd64

Source test:

package main

import (
    "fmt"

    "cloud.google.com/go/datastore"
)

var client *datastore.Client

func main() {
    fmt.Println("Work")
}

Error:

$ go run main.go
# google.golang.org/grpc/internal/transport
..\..\..\..\google.golang.org\grpc\internal\transport\http_util.go:270:23: cannot use hf (type "vendor/golang.org/x/net/http2/hpack".HeaderField) as type
"golang.org/x/net/http2/hpack".HeaderField in argument to d.processHeaderField
..\..\..\..\google.golang.org\grpc\internal\transport\http_util.go:675:23: cannot use "golang.org/x/net/http2/hpack".NewDecoder(http2InitHeaderTableSize,
nil) (type *"golang.org/x/net/http2/hpack".Decoder) as type *"vendor/golang.org/x/net/http2/hpack".Decoder in assignment

Solution

  • Go requires you make use of any package that you import. In this case you are importing "cloud.google.com/go/datastore" but not doing anything with it. The global variable that you declared is also not being used. Since it seems you are just trying to test, so I would recommend you do something with it (atleast print it). Like-

    package main
    
    import (
        "fmt"
    
        "cloud.google.com/go/datastore"
    )
    
    var client *datastore.Client
    
    func main() {
        fmt.Println(client)
    }