fix the bug of undefined:io
This commit is contained in:
parent
8952539b0f
commit
ec1ae9504e
|
|
@ -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 {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue