gcli2api / internal /syncer /util.go
a3216's picture
chore: 同步到上游 1.12.0-panel + 凭证同步/独立启动器/保活
6d60378 verified
Raw History Blame Contribute Delete
415 Bytes
package syncer
import (
"fmt"
"os"
"strings"
)
// readTrimmedFile 读一个文本文件并去掉首尾空白(token 文件常用)。
func readTrimmedFile(fp string) (string, error) {
raw, err := os.ReadFile(fp)
if err != nil {
return "", fmt.Errorf("读取 %s 失败: %w", fp, err)
}
s := strings.TrimSpace(string(raw))
if s == "" {
return "", fmt.Errorf("%s 内容为空", fp)
}
return s, nil
}