I was able to go through the whole process of setting up and installing github.com/augustoroman/v8 -- I built it's V8 dependency manually. When I run go test
I get the following result:
PASS
ok github.com/augustoroman/v8 9.433s
I installed the package at $GOPATH/src/github.com/augustoroman/v8
. Everything seems to work well on OS X so far. However when I attempt importing with import "github.com/augustoroman/v8"
in my own separate project I get a complaint.
Remembering back I realized that I have GO111MODULE=on
enabled. This prompted me to add a go.mod with the following in the root of the v8 folder:
module github.com/augustoroman/v8
go 1.12
When I attempt running I get another error:
go: finding github.com/augustoroman/v8 latest
go: downloading github.com/augustoroman/v8 v8.0.0-20190418063024-4b66934a28a7
main.go:3:8: unknown import path "github.com/augustoroman/v8": cannot find module providing package github.com/augustoroman/v8
Basically it seems that the package works accordingly however either the GO111MODULE setting is messing it up or I've installed the package at an incorrect location. Tbh the GO111MODULE settings are doubly confusing on top of Go's already rigid setup/structure.
Any suggestions on how to debug this issue?
When GO111MODULE=on
is set, Go doesn't use GOPATH/src
packages, rather, it uses $GOPATH/pkg/mod
. (ref, official blog)
So, Installing changed package in $GOPATH/src/github.com/augustoroman/v8
won't work.
As a workaround, you can use replace
directive in go.mod
file where this modified package is needed.
For, example, If you are using github.com/augustoroman/v8
in example.com/me/hello
project, then use replace
in go.mod
file of example.com/me/hello
.
It can be any of absolute or relative on-disk location,
module example.com/me/hello
require (
github.com/me/some-repo v0.0.0
)
replace (
github.com/augustoroman/v8 => /absolute/gopath/src/github.com/augustoroman/v8
)
or, even better (more idiomatic!), your fork repository in github.
module example.com/me/hello
require (
github.com/me/some-repo v0.0.0
)
replace (
github.com/augustoroman/v8 => github.com/me/v8
)