-1

I'm extending an existing database driver (https://github.com/MonetDB/MonetDB-Go).

I use the github url as an import in my main.go, and in the go.mod:

replace github.com/fajran/go-monetdb@latest => github.com/MonetDB/MonetDB-Go v1.0.0

Yet when I try to go get/go install/go run it, it says:

main.go:7:2: no required module provides package github.com/MonetDB/MonetDB-Go; to add it:
    go get github.com/MonetDB/MonetDB-Go

Am I doing something wrong, or is it because it's a fork?

blackgreen
  • 34,072
  • 23
  • 111
  • 129
MitchellWeg
  • 49
  • 1
  • 7
  • In general you **cannot** get a "Github fork" of a Go package to compile and run properly. Only trivial cases work (by using replace). – Volker May 03 '21 at 11:55
  • You're changed the module name to your fork, the old package was not part of a module, and there is only one package within the module. What are you trying to do with `replace` here? You should be able to just import `github.com/MonetDB/MonetDB-Go/src` – JimB May 03 '21 at 14:30

1 Answers1

1

You don't need to replace anything, since you already import github.com/MonetDB/MonetDB-Go.

Your error comes from the fact that the source code in github.com/MonetDB/MonetDB-Go is under the src directory.


Final go.mod file:

module example

go 1.16

require github.com/MonetDB/MonetDB-Go v1.0.0

Final main.go:

package main

import (
    "fmt"
    "github.com/MonetDB/MonetDB-Go/src"
)

func main() {
    fmt.Println(monetdb.MAPI_STATE_INIT) // prints 0
}
blackgreen
  • 34,072
  • 23
  • 111
  • 129