code fix
This commit is contained in:
parent
fdbbc02d0a
commit
2d1ac09ba1
1 changed files with 18 additions and 16 deletions
24
tree.go
24
tree.go
|
@ -33,12 +33,13 @@ func BuildTree(dirPath string, meta []string) (Tree, error) {
|
|||
}
|
||||
|
||||
func PopulateTree(sourcePath string, destPath string, meta []string) error {
|
||||
err = fixFormat(sourcePath)
|
||||
err := fixFormat(sourcePath)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
id, err := getMaxId(sourcePath)
|
||||
var id int64 = 0
|
||||
id, err = getMaxId(sourcePath)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -87,9 +88,9 @@ func fixFormat(dir string) error {
|
|||
format = false
|
||||
}
|
||||
|
||||
if (format) {
|
||||
if format {
|
||||
line = strings.Trim(line, " ")
|
||||
if (line != "") {
|
||||
if line != "" {
|
||||
content = content + "\n" + line
|
||||
}
|
||||
} else {
|
||||
|
@ -314,20 +315,20 @@ func readFile(file fs.FileInfo, fullPath string, category []string, meta []strin
|
|||
}
|
||||
for _, option := range meta {
|
||||
if strings.HasPrefix(line, option) {
|
||||
line = strings.TrimPrefix(line, option + ":")
|
||||
line = strings.TrimPrefix(line, option+":")
|
||||
f.Meta[option] = strings.Trim(line, " ")
|
||||
}
|
||||
}
|
||||
}
|
||||
osf.Close()
|
||||
_ = osf.Close()
|
||||
|
||||
return f, nil
|
||||
}
|
||||
|
||||
func ReadFileContent(file File) (string, error) {
|
||||
osf, err := os.Open(path)
|
||||
osf, err := os.Open(file.FullPath)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
return "", err
|
||||
}
|
||||
|
||||
content := ""
|
||||
|
@ -342,13 +343,13 @@ func ReadFileContent(file File) (string, error) {
|
|||
continue
|
||||
}
|
||||
|
||||
if (isMetaPart) {
|
||||
if isMetaPart {
|
||||
continue
|
||||
}
|
||||
|
||||
if (removeEmptyLine) {
|
||||
if removeEmptyLine {
|
||||
line = strings.Trim(line, " ")
|
||||
if (line == "") {
|
||||
if line == "" {
|
||||
continue
|
||||
} else {
|
||||
removeEmptyLine = false
|
||||
|
@ -357,6 +358,7 @@ func ReadFileContent(file File) (string, error) {
|
|||
|
||||
content = content + "\n" + line
|
||||
}
|
||||
_ = osf.Close()
|
||||
|
||||
return content, nil
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue