• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

yyle88 / syntaxgo / 18836268722

27 Oct 2025 07:06AM UTC coverage: 52.137% (-7.3%) from 59.469%
18836268722

push

github

yyle88
Remove deprecated AST merge functions and upgrade dependencies

  - Remove merge_package.go using deprecated ast.MergePackageFiles API
  - Clean up syntaxgo_ast package to use modern Go AST APIs
  - Upgrade Go version from 1.22.8 to 1.24.0

13 of 122 new or added lines in 8 files covered. (10.66%)

20 existing lines in 2 files now uncovered.

622 of 1193 relevant lines covered (52.14%)

7.46 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/internal/utils/utils.go
1
// Package utils provides internal helper functions for syntaxgo
2
// These utilities serve the main syntaxgo package and are not exported
3
// Functions here handle common operations like string manipulation and file checks
4
//
5
// Design Decision: Keep utils internal to avoid circular dependencies
6
// Since syntaxgo is a base package, external tool packages might import it
7
// Extracting these utils to a separate package could create circular references
8
// While project-level circular deps compile, they complicate version management
9
//
10
// utils 包为 syntaxgo 提供内部辅助函数
11
// 这些工具服务于主 syntaxgo 包且不对外导出
12
// 此处函数处理常见操作,如字符串操作和文件检查
13
//
14
// 设计决策:保持 utils 为内部包以避免循环依赖
15
// 由于 syntaxgo 是基础包,外部工具包可能会引用它
16
// 将这些工具提取到独立包可能造成循环引用
17
// 虽然项目级循环依赖能编译,但会使版本管理复杂化
18
package utils
19

20
import (
21
        "os"
22
        "path/filepath"
23
        "unicode"
24
)
25

26
// SetPrefix2Strings adds a prefix to each string in the slice
27
// Returns a new slice with each string prefixed
28
//
29
// SetPrefix2Strings 为切片中的每个字符串添加前缀
30
// 返回包含每个添加前缀字符串的新切片
31
func SetPrefix2Strings(prefix string, a []string) (results []string) {
×
32
        results = make([]string, 0, len(a))
×
33
        for _, v := range a {
×
34
                results = append(results, prefix+v)
×
35
        }
×
36
        return results
×
37
}
38

39
// SafeMerge combines multiple slices into a single slice
40
// Pre-allocates space based on combined length to optimize performance
41
//
42
// SafeMerge 将多个切片合并为单个切片
43
// 根据组合长度预分配空间以优化性能
UNCOV
44
func SafeMerge[V any](a ...[]V) (res []V) {
×
UNCOV
45
        res = make([]V, 0, SumLength(a...))
×
UNCOV
46
        for _, slice := range a {
×
UNCOV
47
                res = append(res, slice...)
×
UNCOV
48
        }
×
UNCOV
49
        return res
×
50
}
51

52
// SumLength calculates the combined length of slices
53
// Returns the sum of lengths across input slices
54
//
55
// SumLength 计算所有切片的组合长度
56
// 返回输入切片的长度总和
UNCOV
57
func SumLength[V any](a ...[]V) (n int) {
×
UNCOV
58
        for _, slice := range a {
×
UNCOV
59
                n += len(slice)
×
UNCOV
60
        }
×
UNCOV
61
        return n
×
62
}
63

64
// C0IsUppercase checks if the first rune in the string is uppercase
65
// Returns false when the string has no content
66
//
67
// C0IsUppercase 检查字符串的第一个字符是否为大写
68
// 当字符串没有内容时返回 false
69
func C0IsUppercase(s string) bool {
×
70
        runes := []rune(s)
×
71
        if len(runes) > 0 {
×
72
                return unicode.IsUpper(runes[0])
×
73
        }
×
74
        return false
×
75
}
76

77
// SetDoubleQuotes wraps a string with double quotes
78
// Returns the string surrounded with double quote characters
79
//
80
// SetDoubleQuotes 用双引号包装字符串
81
// 返回用双引号字符包围的字符串
UNCOV
82
func SetDoubleQuotes(s string) string {
×
UNCOV
83
        return "\"" + s + "\""
×
UNCOV
84
}
×
85

86
// IsGoSourceFile checks if the file info represents a Go source file
87
// Returns true if the file has .go extension and is not a DIR
88
//
89
// IsGoSourceFile 检查文件信息是否代表 Go 源文件
90
// 如果文件具有 .go 扩展名且不是 DIR 则返回 true
UNCOV
91
func IsGoSourceFile(info os.FileInfo) bool {
×
UNCOV
92
        return (!info.IsDir()) && (filepath.Ext(info.Name()) == ".go")
×
UNCOV
93
}
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc