[本文出自天外归云的博客园]
问题是
gazelle: imports git.code.oa.com/atta/attaapi-go and git.code.oa.com/atta/attaapi_go resolve to the same repository rule name com_oa_code_git_atta_attaapi_go
原因是
废弃库,不让引入大仓中
算法是
当你执行 go mod graph | grep "xxx" 命令找废弃依赖引入源的时候
代码是
import subprocess def exec_cmd(cmd_str): p = subprocess.Popen(cmd_str, shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) refs_bytes = p.stdout.read() refs_str = refs_bytes.decode('UTF-8') return refs_str def get_refs(ref_target, top_target): refs_str = exec_cmd(f'go mod graph | grep {ref_target}') refs = refs_str.split("\n") for ref in [ref for ref in refs if len(ref.split(" ")) == 2]: left_right = ref.split(" ") left = left_right[0] right = left_right[1] if ref_target not in right: continue if top_target in left: print(right) continue get_refs(left, top_target) if __name__ == '__main__': get_refs("废弃以来库", "小仓地址")
之后是
去大仓的deps.bzl里找到这些依赖的版本,更新到小仓的go.mod文件里,然后go mod tidy就可以了