背景:

    本人java出身,转行golang,有点类似于springboot starter 。当然好处就不多介绍了,你懂得

目标:

     自定义module,开源公共代码库。

工程结构:

          golang 利用github自定义module 踩坑系列 类似于「springboot starter 一毛一样」_自定义

          golang 利用github自定义module 踩坑系列 类似于「springboot starter 一毛一样」_java_02

          默认创建golib-config-center-client项目之后的样子

  遇到的问题:

          golang 利用github自定义module 踩坑系列 类似于「springboot starter 一毛一样」_golang_03

         module declares its path as: 模块将其路径声明为:
         but was required as:但被要求:

  百度各种解决办法(依然不好使):

         1.使用replace 替代 这是一种

         2.什么设置环境变量

         3.什么ideal工具问题

   解决方法:

      各种阅读资料、排查、发现问题出在go.mod文件中

       golang 利用github自定义module 踩坑系列 类似于「springboot starter 一毛一样」_golang_04

       请注意module 对应的名称是github的地址,而不是项目名称

golang 利用github自定义module 踩坑系列 类似于「springboot starter 一毛一样」_百度_05

Go模块中规范了一个重要原则

If an old package and a new package have the same import path, the new package must be backwards compatible with the old package.3

如果旧包和新包具有相同的导入路径,新包必须向后兼容旧包。

小广告系列:

    本人热衷于技术,希望提供些许轮子,提升效和提质。

    仓库地址:https:///codefocus-club/