mirror of
https://github.com/lionsoul2014/ip2region.git
synced 2025-12-08 19:25:22 +00:00
fix the bug of undefined:io
This commit is contained in:
parent
8952539b0f
commit
ec1ae9504e
@ -11,6 +11,7 @@ package xdb
|
||||
import (
|
||||
"embed"
|
||||
"fmt"
|
||||
"io"
|
||||
"os"
|
||||
"strconv"
|
||||
"strings"
|
||||
@ -182,7 +183,7 @@ func LoadContentFromFile(dbFile string) ([]byte, error) {
|
||||
return cBuff, nil
|
||||
}
|
||||
|
||||
// LoadContentFromFS 提供了一个通用的方法来从 embed.FS 中加载文件内容
|
||||
// LoadContentFromFS load the whole xdb binary from embed.FS
|
||||
func LoadContentFromFS(fs embed.FS, filePath string) ([]byte, error) {
|
||||
file, err := fs.Open(filePath)
|
||||
if err != nil {
|
||||
@ -190,7 +191,6 @@ func LoadContentFromFS(fs embed.FS, filePath string) ([]byte, error) {
|
||||
}
|
||||
defer file.Close()
|
||||
|
||||
// 读取文件内容到字节数组
|
||||
var cBuff []byte
|
||||
cBuff, err = io.ReadAll(file)
|
||||
if err != nil {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user