#Dependencies issues https://github.com/uber/h3-go

27 messages · Page 1 of 1 (latest)

vital saddle
#

Hey guys, I just got hands on a repo that uses this depependecy and I found something that I could not solve.

I made a simple project and pulled the dependecy, but when I try to run the example it just does not find the dep, and it is giving me an error could not import github.com/uber/h3-go/v4 (no required module provides package "github.com/uber/h3-go/v4"), which is weird because on the go.mod I can see the dependency imported. ```module h3-uber

go 1.21.6

require github.com/uber/h3-go/v4 v4.1.0```

I just copied the example provided on the readme but it does not work 😦

package main

import (
    "fmt"

    h3 "github.com/uber/h3-go/v4"
)

func main() {

    latLng := h3.NewLatLng(37.775938728915946, -122.41795063018799)
    resolution := 9 // between 0 (biggest cell) and 15 (smallest cell)

    cell := h3.LatLngToCell(latLng, resolution)

    fmt.Printf("%s", cell)

}

This error is the same one I am getting on my original repo.

Did I missed something?? Thanks in advance.

pseudo leaf
#

are you behind a custom module proxy?

#

i don’t know the procedure to get more debug information on the module lookup off the top of my head, but i’d dig more into that

#

what you’re doing looks fine to me

vital saddle
#

Hey thanks for your time, as you mentioned everithing looks fine and that is why i am so confused.

#

This repo requires CGO to be enabled (which I did), is it possible to run these projects that requires c with the command go run main.go? Or do I need to build it first?

I tried with the go run commnad and I got this error: github.com/uber/h3-go/v4: build constraints exclude all Go files in /home/titan/go/pkg/mod/github.com/uber/h3-go/[email protected]

vital saddle
pseudo leaf
#

you don’t need to build it yourself, but you definitely need a cgo setup (i.e. a compatible C compiler, CGO_ENABLED=1, and any dependencies that library might need, if any)

#

i hadn’t thought that would manifest in an error like this, but it kinda makes sense in that it doesn’t see the package if all files in it are excluded from the build

vital saddle
#

Maybe these files are being excluded because the go can not resolve the dependency at first?

pseudo leaf
#

i’m not really sure what you mean by that

#

what does go env CGO_ENABLED report?

vital saddle
pseudo leaf
#

okay, so you do not have cgo enabled

#

that would do it

#

try running with CGO_ENABLED=1, but make sure you have a compatible compiler set up

vital saddle
#

I will try. Just to be clear what i meant is that me error come even before running in, the IDE is trowing me the error i first reported.

pseudo leaf
#

that’s just the language server, that doesn’t mean much

#

compiler errors are the source of truth here

vital saddle
#

I see, so I need to install a c compiler then, may I know which one do you use? I am on ubuntu 22.04.3

pseudo leaf
#

gcc is pretty much the default choice

#

clang is an option too, it’s a little more niche

#

either should work

vital saddle
#

Ok i will try installing it

#

So just for curiosity, how do you debugg a project like this??

#

I mean when you have dependencies with c

vital saddle
#

Ok I managed to run it @pseudo leaf Thank you very much.