Git Product home page Git Product logo

go-module-test's Introduction

这个项目内包含三个 project(即,有 3 个 module),其中 mod1 引用 mod2,mod2 引用 mod3 mod1 go.mod main.go mod2 go.mod mod2.go mod3 go.mod mod3.go

实验的设计说明

上面 mod1 是我要进行编译的 module,mod1 直接引用 mod2,mod2 直接依赖 mod3,所以 mod1 间接依赖 mod3,mod1/go.mod 也证明了这点。 但是注意,mod2/go.mod 中,我给出的 replace 是一个错误的地址,这个文件夹是不存在的,此外,我在 mod1/go.mod 给出了正确的 replace。

实验结果

$ cd mod1
$ go build
$ .\mod1
Now in mod2
Now in mod3

可以看到,是可以正常编译并执行的,这至少说明了两个问题:

  • mod1 中的 replace 直接覆盖了全局的 replace,不然的话,mod2 是肯定找不到 mod3 的;
  • replace 会对间接依赖生效,因为 mod1 就是间接依赖 mod3。

结果分析

只有当前 build 的 module 的 replace 会被保留,其它的都会被忽略,所以才有了上面的实验结果。当然这些都是我结合实验和文档给出的一些理解推测,可能会有一定的偏差。

go-module-test's People

Contributors

gzltommy avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.