Fix: colon exist while no attr at the end of line (#86)

This commit is contained in:
Loyalsoldier 2020-07-28 09:37:59 +08:00 committed by GitHub
parent 99a1b9f37e
commit 4130e0a5b9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -47,10 +47,10 @@ func (l *ParsedList) toPlainText(listName string) error {
for _, attr := range entry.Attrs {
attrString += "@" + attr.GetKey() + ","
}
attrString = strings.TrimRight(attrString, ",")
attrString = strings.TrimRight(":"+attrString, ",")
}
// Entry output format is: type:domain.tld:@attr1,@attr2
entryBytes = append(entryBytes, []byte(entry.Type+":"+entry.Value+":"+attrString+"\n")...)
entryBytes = append(entryBytes, []byte(entry.Type+":"+entry.Value+attrString+"\n")...)
}
if err := ioutil.WriteFile(listName+".txt", entryBytes, 0644); err != nil {
return fmt.Errorf(err.Error())