fix the bug of undefined:io

This commit is contained in:
lion 2025-05-05 19:46:13 +08:00
parent 8952539b0f
commit ec1ae9504e
1 changed files with 2 additions and 2 deletions

View File

@ -11,6 +11,7 @@ package xdb
import ( import (
"embed" "embed"
"fmt" "fmt"
"io"
"os" "os"
"strconv" "strconv"
"strings" "strings"
@ -182,7 +183,7 @@ func LoadContentFromFile(dbFile string) ([]byte, error) {
return cBuff, nil return cBuff, nil
} }
// LoadContentFromFS 提供了一个通用的方法来从 embed.FS 中加载文件内容 // LoadContentFromFS load the whole xdb binary from embed.FS
func LoadContentFromFS(fs embed.FS, filePath string) ([]byte, error) { func LoadContentFromFS(fs embed.FS, filePath string) ([]byte, error) {
file, err := fs.Open(filePath) file, err := fs.Open(filePath)
if err != nil { if err != nil {
@ -190,7 +191,6 @@ func LoadContentFromFS(fs embed.FS, filePath string) ([]byte, error) {
} }
defer file.Close() defer file.Close()
// 读取文件内容到字节数组
var cBuff []byte var cBuff []byte
cBuff, err = io.ReadAll(file) cBuff, err = io.ReadAll(file)
if err != nil { if err != nil {