dqndc26628 2019-05-18 21:34
浏览 164

使用GO111MODULE = on安装augustoroman / v8时遇到问题

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?

  • 写回答

1条回答 默认 最新

  • dqsvf28682 2019-05-19 12:26
    关注

    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
    )
    
    评论

报告相同问题?

悬赏问题

  • ¥500 火焰左右视图、视差(基于双目相机)
  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本