File size: 415 Bytes
6d60378
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
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
}