简体   繁体   English

go-git:创建短哈希(a83ad00 而不是 a83ad004b3c5...)

[英]go-git: Create short hash (a83ad00 instead of a83ad004b3c5...)

I am using go-git and I would like to print the short hash.我正在使用go-git ,我想打印短哈希。

I mean, for example "a83ad00" instead of "a83ad004b3c5971a194ba86b96fe313b94bbcde7".我的意思是,例如“a83ad00”而不是“a83ad004b3c5971a194ba86b96fe313b94bbcde7”。

I looked at the source code of got-git, but could not find a corresponding function.看了下got-git的源码,没找到对应的函数。

How to get the short "partial" hash?如何获得简短的“部分”哈希?

Couldn't you substring it?你不能子串吗? I do not see any from the API docs我没有从API 文档中看到任何内容

full := repo.Head().Hash().String()
short := full[0:8]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM