xxxapi/middlewares imports xxx.xxxgitlab.net/x/xx/xxx/econtext: xxx.xxxgitlab.net/x/xx/xxx@v1.6.5-rc.7.0.20250609085545-4855369c0f1e: invalid version: git ls-remote -q origin in /go/pkg/mod/cache/vcs/672638ca2205d3f2cdc0288db28840b769e58250b95fbbd31e553c6c8076fc3c: exit status 128: remote: remote: ======================================================================== remote: remote: The project you were looking for could not be found or you don't have permission to view it. remote: remote: ======================================================================== remote: fatal: Could not read from remote repository. Please make sure you have the correct access rights and the repository exists.
$ go get -x xxx.xxxgitlab.net/x/xx/xxx # get https://xxx.xxxgitlab.net/x/xx/xxx?go-get=1 # get https://xxx.xxxgitlab.net/x/xx/xxx?go-get=1: 200 OK (0.063s) # get https://xxx.xxxgitlab.net/docmxini/xx?go-get=1 # get https://xxx.xxxgitlab.net/x/xx?go-get=1: 200 OK (0.016s) mkdir -p /go/pkg/mod/cache/vcs # git3 https://xxx.xxxgitlab.net/x/xx.git # lock /go/pkg/mod/cache/vcs/672638ca2205d3f2cdc0288db28840b769e58250b95fbbd31e553c6c8076fc3c.lock # /go/pkg/mod/cache/vcs/672638ca2205d3f2cdc0288db28840b769e58250b95fbbd31e553c6c8076fc3c for git3 https://xxx.xxxgitlab.net/x/fx.git cd /go/pkg/mod/cache/vcs/672638ca2205d3f2cdc0288db28840b769e58250b95fbbd31e553c6c8076fc3c; git -c log.showsignature=false log --no-decorate -n1 '--format=format:%H %ct %D' 4855369c0f1e -- 0.002s # cd /go/pkg/mod/cache/vcs/672638ca2205d3f2cdc0288db28840b769e58250b95fbbd31e553c6c8076fc3c; git -c log.showsignature=false log --no-decorate -n1 '--format=format:%H %ct %D' 4855369c0f1e -- cd /go/pkg/mod/cache/vcs/672638ca2205d3f2cdc0288db28840b769e58250b95fbbd31e553c6c8076fc3c; git ls-remote -q origin 0.232s # cd /go/pkg/mod/cache/vcs/672638ca2205d3f2cdc0288db28840b769e58250b95fbbd31e553c6c8076fc3c; git ls-remote -q origin # get https://xxx.xxxgitlab.net/x/xx.git # get https://xxx.xxxgitlab.net/x/xx.git: 200 OK (0.076s) cd /go/pkg/mod/cache/vcs/672638ca2205d3f2cdc0288db28840b769e58250b95fbbd31e553c6c8076fc3c; git tag -l 0.002s # cd /go/pkg/mod/cache/vcs/672638ca2205d3f2cdc0288db28840b769e58250b95fbbd31e553c6c8076fc3c; git tag -l go: xxx.xxxgitlab.net/x/xx/xxx@v1.6.5-rc.7.0.20250609085545-4855369c0f1e: invalid version: git ls-remote -q origin in /go/pkg/mod/cache/vcs/672638ca2205d3f2cdc0288db28840b769e58250b95fbbd31e553c6c8076fc3c: exit status 128: remote: remote: ======================================================================== remote: remote: The project you were looking for could not be found or you don't have permission to view it. remote: remote: ======================================================================== remote: fatal: Could not read from remote repository. Please make sure you have the correct access rights and the repository exists.
上面最后的命令报错,cd 进去执行下看看:
1 2 3 4 5 6 7 8 9 10 11 12 13
$ cd /go/pkg/mod/cache/vcs/672638ca2205d3f2cdc0288db28840b769e58250b95fbbd31e553c6c8076fc3c $ git ls-remote remote: remote: ======================================================================== remote: remote: The project you were looking for could not be found or you don't have permission to view it. remote: remote: ======================================================================== remote: fatal: Could not read from remote repository.
Please make sure you have the correct access rights and the repository exists.
$ git ls-remote | head From git@xxx.xxxgitlab.net:x/xx/xxx.git 74f35a28ecc0f9721a49c41fb5d7bffa071d1502 HEAD 295c3a79dfc0d27022459d0cec21411031edd5e8 refs/heads/0xxx ...
gitlab subgroup
搜了下,发现是 gitlab 的鉴权和 golang 的 get 逻辑冲突,双方都认为对方不规范,谁都不让谁,具体见文章:
defreplace_repo(repo_list, mod_json, mod_path): if mod_json['Replace']: mod_replace_list = [ i['Old']['Path'] for i in mod_json['Replace']] repo_list = [repo for repo in repo_list if repo notin mod_replace_list] iflen(repo_list) == 0: logging.info("已经全部替换") return
replace_list = [ i for i in mod_json['Require'] if i['Path'] in repo_list and (not i.get('Indirect', False))] iflen(replace_list) == 0: logging.error("未找到需要替换的仓库: %s", ','.join(repo_list)) return withopen(mod_path, 'a', encoding='utf-8') as f: for item in replace_list: replace_str = "replace {0} => {0}.git {1}".format(item['Path'], item['Version']) logging.info("添加 %s", replace_str) f.writelines(replace_str+'\n')