Skip to content

Commit 03bfddc

Browse files
normal-codernetworm
authored andcommitted
docs(go-git): translate go-git documentation
1 parent 73d0e36 commit 03bfddc

File tree

1 file changed

+26
-26
lines changed

1 file changed

+26
-26
lines changed
Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
=== go-git
22

33
(((go-git)))(((Go)))
4-
In case you want to integrate Git into a service written in Golang, there also is a pure Go library implementation.
5-
This implementation does not have any native dependencies and thus is not prone to manual memory management errors.
6-
It is also transparent for the standard Golang performance analysis tooling like CPU, Memory profilers, race detector, etc.
4+
如果你想将 Git 集成到用 Golang 编写的服务中,这里还有一个纯 Go 库的实现。这个库的实现没有任何原生依赖,因此不易出现手动管理内存的错误。
5+
它对于标准 Golang 性能分析工具(如 CPU、内存分析器、竞争检测器等)也是透明的。
76

8-
go-git is focused on extensibility, compatibility and supports most of the plumbing APIs, which is documented at https://github.com/src-d/go-git/blob/master/COMPATIBILITY.md[].
7+
go-git 专注于可扩展性、兼容性并支持大多数管道 API,记录在 https://github.com/src-d/go-git/blob/master/COMPATIBILITY.md[].
98

10-
Here is a basic example of using Go APIs:
9+
以下是使用 Go API 的基本示例:
1110

1211
[source, go]
1312
-----
@@ -19,31 +18,31 @@ r, err := git.PlainClone("/tmp/foo", false, &git.CloneOptions{
1918
})
2019
-----
2120

22-
As soon as you have a `Repository` instance, you can access information and perform mutations on it:
21+
你只要拥有一个 `Repository` 实例,就可以访问相应仓库信息并对其进行改变:
2322

2423

2524
[source, go]
2625
-----
27-
// retrieves the branch pointed by HEAD
26+
// 获取 HEAD 指向的分支
2827
ref, err := r.Head()
2928
30-
// get the commit object, pointed by ref
29+
// 获取由 ref 指向的提交对象
3130
commit, err := r.CommitObject(ref.Hash())
3231
33-
// retrieves the commit history
32+
// 检索提交历史
3433
history, err := commit.History()
3534
36-
// iterates over the commits and print each
35+
// 遍历并逐个打印提交
3736
for _, c := range history {
3837
fmt.Println(c)
3938
}
4039
-----
4140

4241

43-
==== Advanced Functionality
42+
==== 高级功能
4443

45-
go-git has few notable advanced features, one of which is a pluggable storage system, which is similar to Libgit2 backends.
46-
The default implementation is in-memory storage, which is very fast.
44+
go-git 几乎没有值得注意的高级功能,其中之一是可插拔存储系统,类似于 Libgit2 后端。
45+
默认实现是内存存储,速度非常快。
4746

4847
[source, go]
4948
-----
@@ -52,35 +51,36 @@ r, err := git.Clone(memory.NewStorage(), nil, &git.CloneOptions{
5251
})
5352
-----
5453

55-
Pluggable storage provides many interesting options.
56-
For instance, https://github.com/src-d/go-git/tree/master/_examples/storage[] allows you to store references, objects, and configuration in an Aerospike database.
54+
可插拔存储提供了许多有趣的选项。
55+
例如,https://github.com/src-d/go-git/tree/master/_examples/storage[] 允许你在 Aerospike 数据库中存储引用、对象和配置。
5756

58-
Another feature is a flexible filesystem abstraction.
59-
Using https://godoc.org/github.com/src-d/go-billy#Filesystem[] it is easy to store all the files in different way i.e by packing all of them to a single archive on disk or by keeping them all in-memory.
57+
另一个特性是灵活的文件系统抽象。
58+
使用 https://godoc.org/github.com/src-d/go-billy#Filesystem[]
59+
可以很容易以不同的方式存储所有文件,即通过将所有文件打包到磁盘上的单个归档文件或保存它们都在内存中。
6060

61-
Another advanced use-case includes a fine-tunable HTTP client, such as the one found at https://github.com/src-d/go-git/blob/master/_examples/custom_http/main.go[].
61+
另一个高级用例包括一个可微调的 HTTP 客户端,例如 https://github.com/src-d/go-git/blob/master/_examples/custom_http/main.go[] 中的案例。
6262

6363
[source, go]
6464
-----
6565
customClient := &http.Client{
66-
Transport: &http.Transport{ // accept any certificate (might be useful for testing)
66+
Transport: &http.Transport{ // 接受任何证书(可能对测试有用)
6767
TLSClientConfig: &tls.Config{InsecureSkipVerify: true},
6868
},
69-
Timeout: 15 * time.Second, // 15 second timeout
69+
Timeout: 15 * time.Second, // 15 秒超时
7070
CheckRedirect: func(req *http.Request, via []*http.Request) error {
71-
return http.ErrUseLastResponse // don't follow redirect
71+
return http.ErrUseLastResponse // 不要跟随重定向
7272
},
7373
}
7474
75-
// Override http(s) default protocol to use our custom client
75+
// 覆盖 http(s) 默认协议以使用我们的自定义客户端
7676
client.InstallProtocol("https", githttp.NewClient(customClient))
7777
78-
// Clone repository using the new client if the protocol is https://
78+
// 如果协议为 https://,则使用新客户端克隆存储库
7979
r, err := git.Clone(memory.NewStorage(), nil, &git.CloneOptions{URL: url})
8080
-----
8181

8282

83-
==== Further Reading
83+
==== 延伸阅读
8484

85-
A full treatment of go-git's capabilities is outside the scope of this book.
86-
If you want more information on go-git, there's API documentation at https://godoc.org/gopkg.in/src-d/go-git.v4[], and a set of usage examples at https://github.com/src-d/go-git/tree/master/_examples[].
85+
go-git 功能的全面介绍超出了本书的范围。
86+
如果您想了解有关 go-git 的更多信息,请参阅 https://godoc.org/gopkg.in/src-d/go-git.v4[] 上的 API 文档, 以及 https://github.com/src-d/go-git/tree/master/_examples[] 上的系列使用示例。

0 commit comments

Comments
 (0)