阶段十:完成 Go 基础包注释基线清零
This commit is contained in:
1 parent
ea1f2ec430
commit
d1a165f897
14 files changed
+135
-924
No files matched your search
@@ -3,6 +3,7 @@ package version
|
||||
|
||||
import "strings"
|
||||
|
||||
// Version 保存Version,供当前处理流程使用
|
||||
var (
|
||||
Version = "dev"
|
||||
Commit = "unknown"
|
||||
@@ -10,7 +11,9 @@ var (
|
||||
)
|
||||
|
||||
// ShortCommit returns a compact commit identifier suitable for UI display.
|
||||
// ShortCommit 负责ShortCommit相关处理。
|
||||
func ShortCommit() string {
|
||||
// commit 保存commit,供当前处理流程使用
|
||||
commit := strings.TrimSpace(Commit)
|
||||
if len(commit) > 12 {
|
||||
return commit[:12]
|
||||
|
||||
@@ -2,12 +2,15 @@ package version
|
||||
|
||||
import "testing"
|
||||
|
||||
// TestShortCommit 负责TestShortCommit相关处理。
|
||||
func TestShortCommit(t *testing.T) {
|
||||
// original 保存original,供当前处理流程使用
|
||||
original := Commit
|
||||
t.Cleanup(func() { Commit = original })
|
||||
|
||||
Commit = "0123456789abcdef"
|
||||
if got := ShortCommit(); got != "0123456789ab" {
|
||||
if // got 保存got,供当前处理流程使用
|
||||
got := ShortCommit(); got != "0123456789ab" {
|
||||
t.Fatalf("ShortCommit() = %q", got)
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user